【发布时间】:2010-07-21 08:34:50
【问题描述】:
我有代码可以检索 2 种不同形式的目录路径。如果在一种形式中,我选择了打开文件并处理它的路径,当返回到另一种形式时,我会收到 Direcotry Exception 错误。我曾经使用不同的字符串来获取该路径
在第二种形式中,我称之为:
string strFilePath2;
strFilePath2 = Directory.GetCurrentDirectory();
strFilePath2 = Directory.GetParent(strFilePath2).ToString();
strFilePath2 = Directory.GetParent(strFilePath2).ToString();
strFilePath2 = strFilePath2 + "\\ACH";
在我的第一个表单中,我调用了:
strFilePath = Directory.GetCurrentDirectory();
strFilePath = Directory.GetParent(strFilePath).ToString();
strFilePath = Directory.GetParent(strFilePath).ToString();
strFilePath = strFilePath + "\\ACH\\" + Node;
在调试期间,我从第二种形式中获得了选定的路径,但不是我预期的路径。谁能告诉我为什么?
【问题讨论】:
-
请把例外放在问题中。
标签: c# winforms desktop-application