Ejemplo n.º 1
0
        private static void RenameLogAndChilds(string oldDirPath, string newDirPath)
        {
            string oldLogFilePath = GetLogFilePath(oldDirPath);
            string newLogFilePath = GetLogFilePath(newDirPath);

            if (File.Exists(oldLogFilePath) == false)
            {
                return;
            }

            List <string> list = ReadLogFile(oldLogFilePath);

            StreamWriter writer = Digda.WaitAndGetWriter(oldLogFilePath, FileMode.Create);

            foreach (string s in list)
            {
                string   content = s;
                FileType type    = GetFileType(s);
                if (type == FileType.Directory)
                {
                    string dir = GetFileName(s);
                    RenameLogAndChilds(oldDirPath + separator + dir, newDirPath + separator + dir);
                }
                else if (type == FileType.This)
                {
                    content = MakeThisDirInfos(newDirPath, GetSize(s), GetAddSize(s));
                }
                writer.WriteLine(content);
            }

            writer.Close();

            File.Move(oldLogFilePath, newLogFilePath);
            DigdaSysLog.ChangeLogContent(DigdaSysLog.DigChangeLogPath, Path.GetFileName(oldLogFilePath), Path.GetFileName(newLogFilePath));
        }