예제 #1
0
파일: IoHelper.cs 프로젝트: taori/WMPR
        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()));
        }
예제 #2
0
        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);
        }
예제 #3
0
        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);
        }
예제 #4
0
 public string GetEnsuredPath(string path, SpecialFolder folder)
 {
     return(GetEnsuredPath(folder.ToString() + "\\" + path, false));
 }
예제 #5
0
 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);
        }
        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);
        }