Пример #1
0
        public static void Init(string fullPath)
        {
            if (!Directory.Exists(fullPath))
            {
                Console.WriteLine("Введённой вами директории не существует!");
                return;
            }

            DirectoryInfo item = new DirectoryInfo(fullPath);

            if (File.Exists(databasePath + item.Name + ".txt") || File.Exists(folderPathsPath + item.Name + ".txt"))
            {
                Console.WriteLine("Введённая вами директория уже отслеживается");
                return;
            }

            File.Create(folderPathsPath + item.Name + ".txt").Close();
            File.WriteAllText(folderPathsPath + item.Name + ".txt", fullPath, Encoding.Default);

            File.Create(databasePath + item.Name + ".txt").Close();
            TrackedDirectory newDir = new TrackedDirectory(fullPath);

            foreach (TrackedFile dataSet in newDir.files)
            {
                dataSet.mark = Mark.Inited;
            }
            activeDirectory = newDir;
            directories.Add(newDir);
            activeDirectory.Save();
            Console.WriteLine("Директория добавлена под контроль");
        }