Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / Windows Forms / WinForm General / March 2008

Tip: Looking for answers? Try searching our database.

OpenFileDialog.RestoreDirectory no longer works in Vista after     installing VS 2008

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
haroldsphsu@gmail.com - 19 Dec 2007 22:50 GMT
Hi all,

I have an app that relies on OpenFileDialog to change the current
working directory based on the user selection (i.e.
OpenFileDialog.RestoreDirectory = false).  It was working fine on
WinXP/2003/Vista.  But after I install VS 2008 (which also installed
KB110806 (.Net 2.0 Framework SP1), KB929300 (.Net 3.0 Framework SP2)),
the OpenFileDialog no longer changes the current working directory on
Vista.  I wrote a sample app to display the current directory before
and after OpenFileDialog, and the sample app works on:

- XP, with KB110806, KB929300 and .Net Framework 3.5 installed.
- 2003, with KB110806, KB929300, .Net Framework 3.5 installed, VS 2008
installed.

but it doesn't work on Vista with VS 2008 installed.  Here's the code-
behind:

   public partial class Form1 : Form
   {
       public Form1()
       {
           InitializeComponent();
       }

       private void Form1_Load(object sender, EventArgs e)
       {
           _lblBefore.Text =
System.IO.Directory.GetCurrentDirectory();
       }

       private void button1_Click(object sender, EventArgs e)
       {
           DialogResult result = openFileDialog1.ShowDialog();
           if (result == DialogResult.OK)
           {
               _lblAfter.Text =
System.IO.Directory.GetCurrentDirectory();
           }
       }

   }

Does anyone have a similar problem?
RobinS - 04 Jan 2008 04:05 GMT
We are using VS2008, but I haven't noticed this. But then, we retain
the last folder the user selected, and set the InitialDirectory before
opening the file dialog the next time...

Good luck.
RobinS.
GoldMail, Inc.
-------------------------------------------
> Hi all,
>
[quoted text clipped - 40 lines]
>
> Does anyone have a similar problem?
Jacek Kolonko - 04 Mar 2008 06:58 GMT
Hi.

I have exactly the same issue in my application. CurrentDirecory concept
seems to have changed in a .NET 2.0 Framework Update or Windows Vista SP1. In
previous versions OpenFileDialog changed current directory but now it does
not.

But suprisingly RestoreDirectory works as expected. I created a sample
console app that did nothing but display Directory.GetCurrentDirectory()
right before and after OpenFileDialog.ShowDialog is called (InitialDirecotry
left blank). When you run the app again the OpenFileDialog shows the same
folder in which you selected the file, not the CurrentDirectory. And that IS
consistent with previous versions of Windows because if you run the same app
twice on Windows XP w/.NET 2.0 it shows you the CurrentDirectory before
OpenFileDialog but InitialDirectory changes.

So the change seems to be by design. I wish someone clarified how
FileDialogs are supposed to work to avoid such misconceptions such as relying
on CurrentDir.
Signature

Jacek Kolonko [MVP]


Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.