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); }
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))); }
public string EnsureExists() { var appDataDirectory = _environment.GetAppDataDirectoryPath(); var toffeeAppDataDirectory = Path.Combine(appDataDirectory, "Toffee"); if (!_filesystem.DirectoryExists(toffeeAppDataDirectory)) { _filesystem.CreateDirectory(toffeeAppDataDirectory); } return(toffeeAppDataDirectory); }
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); }
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); } } }
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); }
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(); } }