我有一个用VSTO和VS2013编写的Outlook 2013 Addin。我有一个保存文件对话框,我将初始目录设置为网络安装。保存到MailItem.SaveAs()
的路径有效,但当我将其与saveFileDialog1.InitialDirectory = "W:/etc/etc/";
一起使用时,我只将我的文档库作为初始目录。为什么它不起作用?
以下是相关代码:
SaveFileDialog saveFileDialog1 = new SaveFileDialog();
saveFileDialog1.FileName = filename;
saveFileDialog1.InitialDirectory = path;
saveFileDialog1.AddExtension = false;
saveFileDialog1.CheckFileExists = true;
saveFileDialog1.DefaultExt = "\".mht\"";
saveFileDialog1.Filter = "\"MHT Files|*.mht|All Files|*.*\"";
DialogResult result = saveFileDialog1.ShowDialog();
这就是所有相关的代码。 FileName工作正常,路径格式为“W:/ Folder / Folder /”
由于
答案 0 :(得分:3)
似乎InitialDirectory不接受路径中的/但需要反斜杠
此示例适用于我。
SaveFileDialog saveFileDialog1 = new SaveFileDialog();
saveFileDialog1.FileName = "c:/temp/somefilename.txt";
saveFileDialog1.InitialDirectory = "c:\\temp\\";
saveFileDialog1.AddExtension = false;
saveFileDialog1.CheckFileExists = true;
saveFileDialog1.DefaultExt = "\".mht\"";
saveFileDialog1.Filter = "\"MHT Files|*.mht|All Files|*.*\"";
DialogResult result = saveFileDialog1.ShowDialog();
答案 1 :(得分:2)