Sachin Kadam

Sachin Kadam

  • NA
  • 11
  • 37.6k

How to get full path of selected file from OpenFileDialog ?

Sep 9 2011 9:22 AM
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)