如何使用SaveFileDialog在Win 7中显示默认路径?我使用的是InitialDirectory,但无法实现 [英] How to use SaveFileDialog to show default path in Win 7? I use InitialDirectory,but can not make it
本文介绍了如何使用SaveFileDialog在Win 7中显示默认路径?我使用的是InitialDirectory,但无法实现的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
SaveFileDialog sfd = 新 SaveFileDialog();
sfd.AutoUpgradeEnabled = false ;
sfd.InitialDirectory = @" ;
如果(sfd.ShowDialog(此)== DialogResult.OK)
{
// MessageBox.Show(DialogResult.OK.ToString());
字符串 fileSavePath = sfd.FileName;
我使用的是初始目录,但可以创建它.我只想在路径"d \ temp"中显示它?
您知道,win 7与xp不同.有人知道如何更正它吗?
解决方案
在以下位置输入冒号:
sfd.InitialDirectory = @" ; 成为
sfd.InitialDirectory = @" ; pre>否则,这是一个相对目录(基于上次使用的文件夹或当前应用程序目录),如果不存在,则将被忽略.
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?
解决方案
Put a colon in:
sfd.InitialDirectory = @"d\temp";Becomes
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.
这篇关于如何使用SaveFileDialog在Win 7中显示默认路径?我使用的是InitialDirectory,但无法实现的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文