Reputation: 1885
I'm writing a C# application on Linux, and I'd like to store the applications .config files in the user's home directory, i.e.
If the application's name is Foo.exe
~user/.Foo/foo.exe.config
instead of looking for the .config file in the same directory as the assembly. Is this possible?
Upvotes: 2
Views: 2418
Reputation: 414
I believe you can do:
Directory.getCurrentDirectory().
Here is it's resource:
http://msdn.microsoft.com/en-us/library/system.io.directory.getcurrentdirectory(v=vs.110).aspx
Upvotes: 0
Reputation: 12362
Sure. Look into Environment.SpecialFolder.
string appDataDir = Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData);
Remember to use Path.Combine(folder1, folder2) to combine paths in order to make your app cross platform compatible.
Alternatively you could just get the environment variable HOME
:
string homeDir = System.Environment.GetEnvironmentVariable("HOME");
Upvotes: 4