/// <summary> /// Gets the application data directory for a specific product of a specific company. If the folder does not exist, the /// folder is automatically created by this method. /// <para /> /// This method returns a value like [application data]\[company]\[product name]. /// </summary> /// <param name="applicationDataTarget">The application data target.</param> /// <param name="companyName">Name of the company.</param> /// <param name="productName">Name of the product.</param> /// <returns>Directory for the application data.</returns> public static string GetApplicationDataDirectory(ApplicationDataTarget applicationDataTarget, string companyName, string productName) { var rootDirectory = string.Empty; switch (applicationDataTarget) { case ApplicationDataTarget.UserLocal: rootDirectory = Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData); break; case ApplicationDataTarget.UserRoaming: rootDirectory = Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData); break; case ApplicationDataTarget.Machine: rootDirectory = Environment.GetFolderPath(Environment.SpecialFolder.CommonApplicationData); break; default: throw new ArgumentOutOfRangeException("applicationDataTarget"); } string path = Combine(rootDirectory, companyName, productName); if (!Directory.Exists(path)) { Directory.CreateDirectory(path); } return(path); }
/// <summary> /// Gets the application data directory for the company and product as defined the the assembly information of the entry assembly. /// If the entry assembly is <c>null</c>, this method will fall back to the calling assembly to retrieve the information. /// If the folder does not exist, the folder is automatically created by this method. /// <para /> /// This method returns a value like [application data]\[company]\[product name]. /// </summary> /// <returns>Directory for the application data.</returns> public static string GetApplicationDataDirectory(ApplicationDataTarget applicationDataTarget) { var assembly = AssemblyHelper.GetEntryAssembly(); #if !NETFX_CORE if (assembly == null) { assembly = Assembly.GetCallingAssembly(); } #endif return(GetApplicationDataDirectory(applicationDataTarget, assembly.Company(), assembly.Product())); }
public virtual string GetApplicationDataDirectory(ApplicationDataTarget applicationDataTarget) { var applicationDataDirectory = Catel.IO.Path.GetApplicationDataDirectory(applicationDataTarget); return(applicationDataDirectory); }
/// <summary> /// Gets the application data directory for a specific product of a specific company. If the folder does not exist, the /// folder is automatically created by this method. /// <para /> /// This method returns a value like [application data]\[company]\[product name]. /// </summary> /// <param name="applicationDataTarget">The application data target.</param> /// <param name="companyName">Name of the company.</param> /// <param name="productName">Name of the product.</param> /// <returns>Directory for the application data.</returns> public static string GetApplicationDataDirectory(ApplicationDataTarget applicationDataTarget, string companyName, string productName) { var rootDirectory = string.Empty; switch (applicationDataTarget) { case ApplicationDataTarget.UserLocal: rootDirectory = Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData); break; case ApplicationDataTarget.UserRoaming: rootDirectory = Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData); break; case ApplicationDataTarget.Machine: rootDirectory = Environment.GetFolderPath(Environment.SpecialFolder.CommonApplicationData); break; default: throw new ArgumentOutOfRangeException("applicationDataTarget"); } string path = Combine(rootDirectory, companyName, productName); if (!Directory.Exists(path)) { Directory.CreateDirectory(path); } return path; }
/// <summary> /// Gets the application data directory for a specific product. If the folder does not exist, the folder is automatically created by this method. /// <para /> /// This method returns a value like [application data]\[product name]. /// </summary> /// <param name="applicationDataTarget">The application data target.</param> /// <param name="productName">Name of the product.</param> /// <returns>Directory for the application data.</returns> public static string GetApplicationDataDirectory(ApplicationDataTarget applicationDataTarget, string productName) { return GetApplicationDataDirectory(applicationDataTarget, string.Empty, productName); }
/// <summary> /// Gets the application data directory for the company and product as defined the the assembly information of the entry assembly. /// If the entry assembly is <c>null</c>, this method will fall back to the calling assembly to retrieve the information. /// If the folder does not exist, the folder is automatically created by this method. /// <para /> /// This method returns a value like [application data]\[company]\[product name]. /// </summary> /// <returns>Directory for the application data.</returns> public static string GetApplicationDataDirectory(ApplicationDataTarget applicationDataTarget) { var assembly = AssemblyHelper.GetEntryAssembly() ?? Assembly.GetCallingAssembly(); return GetApplicationDataDirectory(applicationDataTarget, assembly.Company(), assembly.Product()); }
/// <summary> /// Gets the application data directory for a specific product. If the folder does not exist, the folder is automatically created by this method. /// <para /> /// This method returns a value like [application data]\[product name]. /// </summary> /// <param name="applicationDataTarget">The application data target.</param> /// <param name="productName">Name of the product.</param> /// <returns>Directory for the application data.</returns> public static string GetApplicationDataDirectory(ApplicationDataTarget applicationDataTarget, string productName) { return(GetApplicationDataDirectory(applicationDataTarget, string.Empty, productName)); }
/// <summary> /// Gets the application data directory for the company and product as defined the the assembly information of the entry assembly. /// If the entry assembly is <c>null</c>, this method will fall back to the calling assembly to retrieve the information. /// If the folder does not exist, the folder is automatically created by this method. /// <para /> /// This method returns a value like [application data]\[company]\[product name]. /// </summary> /// <returns>Directory for the application data.</returns> public static string GetApplicationDataDirectory(ApplicationDataTarget applicationDataTarget) { var assembly = AssemblyHelper.GetEntryAssembly() ?? Assembly.GetCallingAssembly(); return(GetApplicationDataDirectory(applicationDataTarget, assembly.Company(), assembly.Product())); }