2011-09-06 75 views
2

我需要在我的应用程序中找到类似“c:\ users \ programFils \ myProgram \ myFolder”的文件夹而不是 bin文件夹或exe?获取winform程序的文件夹路径

+0

您需要澄清您的问题并更正语法问题。 –

+0

与此Path.GetDirectoryName(Application.ExecutablePath);我进入bin \ debug我不想bin文件夹我wahnt witout bin文件夹 – samy

+0

该文件夹是您在使用Visual Studio进行调试期间程序的沙箱。发布和安装应用程序时,它会有所不同。 –

回答

8

您正在寻找这样的事情?

Path.GetDirectoryName(Application.ExecutablePath).Replace(@"bin\debug\", string.Empty); 
7

此代码返回执行程序集的文件夹路径。

using System.IO; 
using System.Windows.Forms; 

string appPath = Path.GetDirectoryName(Application.ExecutablePath); 
相关问题