Exemplo n.º 1
0
        private void CopyFile(CreateFile file)
        {
            var filePath = NormalizeAndEvaluate(file.FilePath);

            DeleteFile(filePath);
            var directory = Path.GetDirectoryName(filePath);

            _filesystem.CreateDirectory(directory);
            _filesystem.WriteAllBytes(filePath, file.Content);
        }
Exemplo n.º 2
0
            private Task SaveAsync(string filePath, Core.Analysis.AnalysisSnapshot snapshot)
            {
                var directory = Path.GetDirectoryName(filePath);

                //
                _filesystem.CreateDirectory(directory);
                return(_filesystem.OpenWrite(filePath).ContinueWith(x => WriteAnalysisSnapshot(x, snapshot)));
            }
Exemplo n.º 3
0
        public string EnsureExists()
        {
            var appDataDirectory       = _environment.GetAppDataDirectoryPath();
            var toffeeAppDataDirectory = Path.Combine(appDataDirectory, "Toffee");

            if (!_filesystem.DirectoryExists(toffeeAppDataDirectory))
            {
                _filesystem.CreateDirectory(toffeeAppDataDirectory);
            }

            return(toffeeAppDataDirectory);
        }
Exemplo n.º 4
0
        public void Execute()
        {
            var allFiles = filesystem.GetFiles(source);

            foreach (var file in allFiles)
            {
                var command = new FileCopyCommand(filesystem, $"{source}/{file}", $"{destination}/{file}");

                command.Execute();

                children.Push(command);
            }

            filesystem.CreateDirectory(destination);
        }
Exemplo n.º 5
0
        private static void SaveSnapshotAsync(IFilesystem filesystem, BitmapSource screenshot, string destination)
        {
            var encoder = new PngBitmapEncoder();

            using (var stream = new MemoryStream())
            {
                var frame = BitmapFrame.Create(screenshot);
                encoder.Frames.Add(frame);
                encoder.Save(stream);

                stream.Position = 0;

                var destinationDirectory = Path.GetDirectoryName(destination);
                filesystem.CreateDirectory(destinationDirectory);
                using (var fileStream = filesystem.OpenWrite(destination))
                {
                    stream.CopyTo(fileStream);
                }
            }
        }
Exemplo n.º 6
0
        private bool CreateFile(string content, string directory, string fileName)
        {
            var fullPath = $"{directory}/{fileName}";

            if (_filesystem.FileExists(fullPath))
            {
                Console.WriteLine($"Cannot create file \"{fullPath}\" because it already exists.");
                return(false);
            }

            if (!_filesystem.DirectoryExists(directory))
            {
                Console.WriteLine($"Creating directory \"{directory}\"");
                _filesystem.CreateDirectory(directory);
            }

            Console.WriteLine($"Creating file \"{fullPath}\"");
            _filesystem.WriteFile(fullPath, content);

            return(true);
        }
Exemplo n.º 7
0
        public async void MakeNewFolder()
        {
            string parentFolder = fileExplorer.SelectedNode.Tag as string;
            string newFoldename = await FindNewFolderName(parentFolder, "New Folder");

            var path = Path.Combine(parentFolder, newFoldename);

            await _filesystem.CreateDirectory(path);

            var node = new TreeNode {
                Text = newFoldename, Tag = path
            };

            fileExplorer.SelectedNode.Nodes.Add(node);
            fileExplorer.Refresh();

            fileExplorer.AfterLabelEdit += AfterLabelEdit;

            fileExplorer.SelectedNode = node;
            if (!node.IsEditing)
            {
                node.BeginEdit();
            }
        }