示例#1
0
        private static Queue <StorageObject> GetQueue()
        {
            var storageQueue = new Queue <StorageObject>();

            Thread.Sleep(10);
            var storageRootInfo = new DirectoryInfo(Root);

            Thread.Sleep(10);
            var directories = storageRootInfo.GetDirectories("*.*", SearchOption.AllDirectories);

            foreach (var dir in directories)
            {
                var isDirectory   = true;
                var storageObject = new StorageObject(dir.FullName, string.Empty, isDirectory);

                storageQueue.Enqueue(storageObject);
            }

            Thread.Sleep(10);
            var files = storageRootInfo.GetFiles("*.*", SearchOption.AllDirectories);

            foreach (var file in files)
            {
                var fullName    = file.FullName;
                var isDirectory = false;

                Thread.Sleep(10);
                var contest       = File.ReadAllText(fullName);
                var storageObject = new StorageObject(fullName, contest, isDirectory);

                storageQueue.Enqueue(storageObject);
            }

            return(storageQueue);
        }
示例#2
0
        private static void CreateFile(string guid, StorageObject storageObject)
        {
            NullCheck(guid);

            var filePath = storageObject.FullName;

            NullCheck(filePath);

            Thread.Sleep(10);
            var fileContents = File.ReadAllText(filePath);

            Thread.Sleep(10);
            Directory.CreateDirectory($"{Backup}\\{guid}");

            filePath = filePath.Replace(Root + "\\", string.Empty);
            var path = Path.Combine(Backup, guid, filePath);

            Thread.Sleep(10);
            var streamWriter = new StreamWriter(path, false);

            streamWriter.Write(fileContents);
            streamWriter.Close();
        }