Last active
April 27, 2017 08:16
-
-
Save Dehax/12453905bcd94441f620fc68b64ae577 to your computer and use it in GitHub Desktop.
Returns path to the application folder in %LOCALAPPDATA%
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
private static string _localAppFolderPath = null; | |
/// <summary> | |
/// Путь к папке программы в локальной папке пользователя. | |
/// </summary> | |
public static string ApplicationFolderPath | |
{ | |
get | |
{ | |
if (_localAppFolderPath != null) | |
{ | |
return _localAppFolderPath; | |
} | |
string localAppDataPath = Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData, Environment.SpecialFolderOption.Create); | |
StringBuilder sb = new StringBuilder(localAppDataPath); | |
sb.Append(Path.DirectorySeparatorChar); | |
Assembly assembly = Assembly.GetExecutingAssembly(); | |
sb.Append(assembly.GetCustomAttribute<AssemblyCompanyAttribute>().Company); | |
sb.Append(Path.DirectorySeparatorChar); | |
sb.Append(assembly.GetCustomAttribute<AssemblyProductAttribute>().Product); | |
sb.Append(Path.DirectorySeparatorChar); | |
_localAppFolderPath = sb.ToString(); | |
Directory.CreateDirectory(_localAppFolderPath); | |
return _localAppFolderPath; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment