Cannot access virtual drive with OpenFileDialog

D

Dick Swager

I am creating a virtual drive with the subst command at the command prompt
as follows:

subst W: C:\WRoot

Now if I view the directory structure in the Windows Explorer I see that I
have the W: drive available to me

Then I create a file at W:\Test\Test.txt.

But now if I try to access the W: from the OpenFileDialog I do not have the
W: directory available. This was working fine with XP but since I moved to
Vista I have lost the capabilty. How can I get this to work with Vista?

To test I created a C# windows project, added a Button and a TextBox, and
created the button press event handler with the following code

private void button1_Click (object sender, EventArgs e)
{
// Launch a dialog to set or retrieve a file name.
OpenFileDialog dialog = new OpenFileDialog ();
dialog.InitialDirectory = "W:\\";
dialog.RestoreDirectory = true;
dialog.Multiselect = false;
dialog.CheckFileExists = false;

DialogResult result = dialog.ShowDialog ();
if (result != DialogResult.OK)
return;

string fileName = dialog.FileName;

textBox1.Text = fileName;
}


Thanks,
Dick
 
B

Bob Powell [MVP]

This is probably more to do with your machine security settings than the
implementation of the file browser.

Try setting up the share to ensure that password protected sharing is
disabled on both ends of the connection.

--
Bob Powell [MVP]
Visual C#, System.Drawing

Ramuseco Limited .NET consulting
http://www.ramuseco.com

Find great Windows Forms articles in Windows Forms Tips and Tricks
http://www.bobpowell.net/tipstricks.htm

Answer those GDI+ questions with the GDI+ FAQ
http://www.bobpowell.net/faqmain.htm

All new articles provide code in C# and VB.NET.
Subscribe to the RSS feeds provided and never miss a new article.
 
B

Bob Powell [MVP]

Ahh, I see what you're on about now. I'll just shut my mouth....

You're right. What a pain!

--
Bob Powell [MVP]
Visual C#, System.Drawing

Ramuseco Limited .NET consulting
http://www.ramuseco.com

Find great Windows Forms articles in Windows Forms Tips and Tricks
http://www.bobpowell.net/tipstricks.htm

Answer those GDI+ questions with the GDI+ FAQ
http://www.bobpowell.net/faqmain.htm

All new articles provide code in C# and VB.NET.
Subscribe to the RSS feeds provided and never miss a new article.
 
B

Bob Powell [MVP]

I'm guessing that this is because the OpenFileDialog uses the Directory
class to populate the tree and Directory.GetLogicalDrives doesn't see a
substituted drive as a logical drive.

--
Bob Powell [MVP]
Visual C#, System.Drawing

Ramuseco Limited .NET consulting
http://www.ramuseco.com

Find great Windows Forms articles in Windows Forms Tips and Tricks
http://www.bobpowell.net/tipstricks.htm

Answer those GDI+ questions with the GDI+ FAQ
http://www.bobpowell.net/faqmain.htm

All new articles provide code in C# and VB.NET.
Subscribe to the RSS feeds provided and never miss a new article.
 
G

G Himangi

You might want to take a look at the Shell MegaPack file/folder browsing UI
controls from http://www.ssware.com which does not have this limitation.
Mind you, they are commercial though.

G Himangi
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top