2011-08-31 68 views

回答

4

你可以得到當前應用程序的目錄,如下所示:

string appPath = Path.GetDirectoryName(Application.ExecutablePath); 

然後,您需要一個字符串比較看,以檢查是否路徑startswith:

Environment.GetFolderPath(Environment.SpecialFolder.UserProfile); 

或曾經的位置,您想要測試,請參閱here以獲取list os特殊文件夾。這些在每個操作系統版本下都可以正確解析

1
bool isUsersPath = System.Reflection.Assembly.GetExecutingAssembly().Location.StartsWith(System.Environment.GetFolderPath(Environment.SpecialFolder.UserProfile)) 
相關問題