示例#1
0
        public static string ChangeRoot(string file, string oldRootDir, string newRootDir = null)
        {
            if (oldRootDir != null)
            {
                oldRootDir = StringTools.PathFltr(oldRootDir + '\\');

                if (StringTools.StartsWith(file, oldRootDir, true) == false)
                {
                    throw new Exception("Wrong oldRootDir: " + oldRootDir + ", " + file);
                }

                file = file.Substring(oldRootDir.Length);
            }
            if (newRootDir != null)
            {
                file = StringTools.Combine(newRootDir, file);
            }
            return(file);
        }
示例#2
0
        public static void DeleteSubDirsUnhandled(string dir, string[] subDirs)
        {
            foreach (string subDir in subDirs)
            {
                string delDir = "$del_" + Guid.NewGuid().ToString("B");

                {
                    ProcessStartInfo psi = new ProcessStartInfo();

                    psi.WorkingDirectory = dir;
                    psi.FileName         = "cmd.exe";
                    psi.Arguments        = "/C ren \"" + Path.GetFileName(subDir) + "\" " + delDir;
                    psi.CreateNoWindow   = true;
                    psi.UseShellExecute  = false;

                    Process.Start(psi).WaitForExit();
                }

                Directory.Delete(StringTools.Combine(dir, delDir));
            }
        }
示例#3
0
 public static string MakeTempPath()
 {
     return(StringTools.Combine(Environment.GetEnvironmentVariable("TMP"), Guid.NewGuid().ToString("B")));
 }
示例#4
0
 public static string GetTempPath(string relPath)
 {
     return(StringTools.Combine(Environment.GetEnvironmentVariable("TMP"), relPath));
 }
示例#5
0
 public string MakePath()
 {
     return(StringTools.Combine(_rootDir, Guid.NewGuid().ToString("B")));
 }
示例#6
0
 public string GetPath(string relPath)
 {
     return(StringTools.Combine(_rootDir, relPath));
 }