Friday, September 21, 2012

using OpenFileDialog to retrieve file path (directory)

using OpenFileDialog to retrieve file path (directory)

Hi All - I need to write a Silverlight app that will run in browser only (not out of browser). I need to be able to allow the user to select a file, on a network share, and I need to be able to extract that location (full path e.g. \\fileshare\folder1\test.docx) and store that directory as a string.

Ultimately this will be hosted in a MS CRM 4.0 application, however, my reading online so far suggests that what i am trying to do is not possible.

Can anyone clarify this, and if possible, give me a work around?

Many thanks for your time.

Answers & Comments...

Answer: 1

are you using the build-in OpenFileDialog?



Answer: 2

Hi - yes, it's the .Net OpenFileDialog.

It is Silverlight 4, in browser (not out of browser).



Answer: 3
I just tested this and with this code you get the full UNC path where the file is located.  
     OpenFileDialog ofd = new OpenFileDialog();              ofd.InitialDirectory = Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments);              ofd.Filter = "WordFile|*.docx";              if (ofd.ShowDialog() == true)              {                 string folderPath = ofd.File.DirectoryName;              }





No comments:

Post a Comment

Send us your comment related to the topic mentioned on the blog