4
Answers

How to get full path of selected file from OpenFileDialog ?

Sachin Kadam

Sachin Kadam

13y
18.4k
1
hi,

i want to get path of selected file using OpenFileDialog,
but its shown "File operation not permitted. Access to path is denied." error.

I have user following code and want to display full path in text box


OpenFileDialog dlg = new OpenFileDialog();
dlg.Multiselect = false;dlg.Filter = "Video Files (*.mp4)|*.mp4|Video Files (*.mpeg)|*.mpeg|Video Files (*.wmv)|*.wmv";
dlg.FilterIndex = 1;
bool? retval = dlg.ShowDialog();
if (retval != null && retval == true)
{
UploadVideo(dlg.File.Name, dlg.File.OpenRead());
//string filePath = Path.GetDirectoryName(dlg.File.Name);
txtVideoPath.Text = dlg.File.Name;
}

Any idea how to get full path?
Answers (4)