コード例 #1
0
ファイル: FileTools.cs プロジェクト: stackprobe/MusBatch
        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);
        }