Click here to Skip to main content
15,891,136 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
C#
SaveFileDialog sfd = new SaveFileDialog();
sfd.AutoUpgradeEnabled = false;
                   sfd.InitialDirectory = @"d\temp";
                   if (sfd.ShowDialog(this)== DialogResult.OK)
                   {
                      // MessageBox.Show(DialogResult.OK.ToString());
                       string fileSavePath = sfd.FileName;

I use initialdirectory,but can make it.I just want to show it in the path "d\temp“?
You know,win 7 is different from xp.Anybody knows how to correct it?
Posted
Updated 25-Nov-11 22:20pm
v4

1 solution

Put a colon in:
C#
sfd.InitialDirectory = @"d\temp";
Becomes
C#
sfd.InitialDirectory = @"d:\temp";
Otherwise it is a relative directory (based onteh last folder used or the current app directory) which if it doesn't exist will be ignored.
 
Share this answer
 
Comments
PEIYANGXINQU 26-Nov-11 4:28am    
when I use "sfd.AutoUpgradeEnabled = true;" ,it show in a defualt path(not d:\temp);when I use "sfd.AutoUpgradeEnabled = false;" it show in the current app directory;It seems that sfd.InitialDirectory = @"d:\temp"; doesn't do anyting!!!
PEIYANGXINQU 26-Nov-11 4:36am    
if it doesn't exist will be ignored. This is the answer.
At first,I think if it doesn't exist,it will create it automatically.
Thank you ,OriginalGriff!
OriginalGriff 26-Nov-11 4:56am    
You're welcome!

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900