PC Review


Reply
Thread Tools Rate Thread

OpenFileDialog.RestoreDirectory no longer works in Vista afterinstalling VS 2008

 
 
haroldsphsu@gmail.com
Guest
Posts: n/a
 
      19th Dec 2007
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?
 
Reply With Quote
 
 
 
 
RobinS
Guest
Posts: n/a
 
      4th Jan 2008
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.
-------------------------------------------
<(E-Mail Removed)> wrote in message
news:66e58a8a-5b6b-4c04-ace2-(E-Mail Removed)...
> 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?


 
Reply With Quote
 
Jacek Kolonko
Guest
Posts: n/a
 
      4th Mar 2008
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.
--
Jacek Kolonko [MVP]
 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
SQL 2008 no longer works with ACCESS for making queries Ksmnf Microsoft Access Queries 0 17th Oct 2009 01:38 AM
Pivot Table Chart no longer works with Office:MAC 2008 gw1500se Microsoft Excel Charting 4 1st Oct 2008 03:17 PM
FYI - Vista won't restart afterinstalling an Astra 6400 scanner =?Utf-8?B?UmljaA==?= Windows Vista Hardware 0 4th Mar 2007 05:39 AM
How to make the RestoreDirectory property work in an OpenFileDialog Johann Blake Microsoft C# .NET 1 16th Sep 2004 06:27 PM
How to make the RestoreDirectory property work in an OpenFileDialog Johann Blake Microsoft VB .NET 1 16th Sep 2004 06:27 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 11:49 PM.