public static string GetRoamingRoot(SpecialFolder subFolder = SpecialFolder.None) { var sf = Environment.GetFolderPath(Environment.SpecialFolder.CommonApplicationData); if (subFolder == SpecialFolder.None) { return(Path.Combine(sf, RoamingRootName)); } return(Path.Combine(sf, RoamingRootName, subFolder.ToString())); }
public static System.IO.DirectoryInfo GetSpecialFolder(SpecialFolder sfolder) { System.IO.DirectoryInfo di; switch (sfolder) { case SpecialFolder.AppData: di = new DirectoryInfo(R.App.AppData); break; case SpecialFolder.TempData: di = new DirectoryInfo(R.App.AppData); break; default: throw new NotImplementedException($"Cannot defined {sfolder.ToString()} folder in Directory.DelTree"); } if (di.Exists) { Folder(di.FullName); } return(di); }
public override string GetFolderPath(SpecialFolder folder, bool create) { // normal dir var dir = Path.Combine(Far.Api.GetFolderPath(folder), @"FarNet\" + ModuleName); if (create && !Directory.Exists(dir)) { try { Directory.CreateDirectory(dir); } catch (IOException) { // temp dir dir = Path.Combine(Path.GetTempPath(), @"FarNet\" + folder.ToString() + @"\" + ModuleName); if (!Directory.Exists(dir)) { Directory.CreateDirectory(dir); } } } return(dir); }
public string GetEnsuredPath(string path, SpecialFolder folder) { return(GetEnsuredPath(folder.ToString() + "\\" + path, false)); }
public string GetRelativePath(string relativePath, SpecialFolder folder) { return(GetRelativePath(folder.ToString() + "\\" + relativePath)); }
public string CombinePathWithSpecialFolder(string path, SpecialFolder folder) => Path.Combine(path, folder.ToString());
private void AddAndCreateSpecialFolder(SpecialFolder folder, string path) { var combinedPath = Path.Combine(path, folder == SpecialFolder.Root ? string.Empty : folder.ToString()); Directory.CreateDirectory(combinedPath); AddSpecialFolder(folder, combinedPath); }