[英]Using .files/.folders with Mono on Linux
我正在Linux上編寫C#應用程序,我想將應用程序.config文件存儲在用戶的主目錄中,即
如果應用程序的名稱是Foo.exe
~user/.Foo/foo.exe.config
而不是在與程序集相同的目錄中查找.config文件。 這可能嗎?
當然。 查看Environment.SpecialFolder 。
string appDataDir = Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData);
請記住使用Path.Combine(folder1,folder2)組合路徑,以使您的應用程序跨平台兼容。
或者,您可以只獲取環境變量HOME
:
string homeDir = System.Environment.GetEnvironmentVariable("HOME");
我相信你可以做到:
Directory.getCurrentDirectory()。
這是資源:
http://msdn.microsoft.com/en-us/library/system.io.directory.getcurrentdirectory(v=vs.110).aspx
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.