private void LoadFile() { var relPathToFile = FileSelector.GetValue().ToString(); var absPathToFile = URIHelper.ConvertToAbsPath(relPathToFile); if (this.ValidatePath(relPathToFile)) { var fileContent = File.ReadAllText(absPathToFile); Editor.Text = fileContent; DisplaySuccessMessage($@"Successfully loaded file ( {absPathToFile} )"); } }
private void LoadFile() { var relPathToFile = FileSelector.GetValue().ToString(); var absPathToFile = URIHelper.ConvertToAbsPath(relPathToFile); if (File.Exists(absPathToFile)) { var fileContent = File.ReadAllText(absPathToFile); Editor.Text = fileContent; DisplaySuccessMessage($@"Successfully loaded file ( {absPathToFile} ) "); } else { DisplayErrorMessage($"File does not exist ( {absPathToFile} ) "); } }
protected void Save_Click(object sender, EventArgs e) { var relPathToFile = FileSelector.GetValue().ToString(); var absPathToFile = URIHelper.ConvertToAbsPath(relPathToFile); try { File.WriteAllText(absPathToFile, Editor.Text); DisplaySuccessMessage($@"Successfully saved ( {absPathToFile} )"); } catch (Exception ex) { ErrorHelper.LogException(ex); DisplayErrorMessage("Error saving", ErrorHelper.CreateError(ex)); } }