namespace VideoBrowser.Common { using System; using System.IO; using System.Reflection; /// /// Defines the . /// public static class AppEnvironment { #region Constants public const string Name = "Cekli Browser"; public const string LongName = "Cekli Video Browser and Downloader"; public const int ProgressUpdateDelay = 250; public static readonly string ShortName = Assembly.GetExecutingAssembly().GetName().Name; private const string BinariesDirectory = "Binaries"; private const string JsonDirectory = "Json"; private const string LogsDirectory = "Logs"; #endregion Constants #region Properties /// /// Gets the AppBinaryDirectory. /// public static string AppBinaryDirectory => Path.Combine(AppDirectory, BinariesDirectory); /// /// Gets the AppDirectory. /// public static string AppDirectory => AppDomain.CurrentDomain.BaseDirectory; /// /// Gets or sets the Arguments. /// public static string[] Arguments { get; internal set; } /// /// Gets the Author. /// public static string Author => "Yohanes Wahyu Nurcahyo"; /// /// Gets the HomeUrl. /// public static string HomeUrl => "https://yoyokits.github.io/VideoBrowser/welcome.html"; /// /// Gets the ProjectUrl. /// public static string ProjectUrl { get; } = "https://github.com/yoyokits/VideoBrowser"; /// /// Gets the UserLocalApplicationData. /// public static string UserLocalApplicationData { get; } = Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData); /// /// Gets the UserProfile. /// public static string UserProfile { get; } = Environment.GetFolderPath(Environment.SpecialFolder.UserProfile); /// /// Gets the UserVideoFolder. /// public static string UserVideoFolder { get; } = Environment.GetFolderPath(Environment.SpecialFolder.MyVideos); /// /// Gets the Version. /// public static string Version { get; } = $"{Assembly.GetExecutingAssembly().GetName().Version.ToString()}"; #endregion Properties #region Methods /// /// Returns the local app data directory for this program. Also makes sure the directory exists. /// /// The . public static string GetAppDataDirectory() { var path = Path.Combine(UserLocalApplicationData, AppEnvironment.ShortName); if (!Directory.Exists(path)) { Directory.CreateDirectory(path); } return path; } /// /// The application folder. /// /// The specialFolder. /// The . public static string GetFolder(Environment.SpecialFolder specialFolder) => Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData); /// /// Returns the json directory for this program. Also makes sure the directory exists. /// /// The . public static string GetJsonDirectory() { var path = Path.Combine(GetAppDataDirectory(), JsonDirectory); if (!Directory.Exists(path)) { Directory.CreateDirectory(path); } return path; } /// /// Returns the logs directory for this program. Also makes sure the directory exists. /// /// The . public static string GetLogsDirectory() { var path = Path.Combine(GetAppDataDirectory(), LogsDirectory); if (!Directory.Exists(path)) Directory.CreateDirectory(path); return path; } /// /// The GetUserLocalApplicationData. /// /// The . public static string GetUserLocalApplicationData() { var userFolder = UserLocalApplicationData; var appFolder = Path.Combine(userFolder, ShortName); if (!Directory.Exists(appFolder)) { Directory.CreateDirectory(appFolder); } return appFolder; } #endregion Methods } }