private async Task <string> _SaveLocally(IFormFile file, SaveFileOptions options = SaveFileOptions.RandomName, string name = "") { string directoryPath = GetCurrentDirectory() + DirectorySeparatorChar + $@"Storage" + DirectorySeparatorChar; if (Exists(directoryPath) == false) { CreateDirectory(directoryPath); } string localFilePath = string.Empty; if (options == SaveFileOptions.RandomName) { localFilePath = directoryPath + StringOperation.RandomString(10) + GetExtension(file.FileName); } else if (options == SaveFileOptions.SourceName) { localFilePath = directoryPath + file.FileName.Replace(" ", "_"); } else { localFilePath = directoryPath + name; } var fileStream = new FileStream(localFilePath, FileMode.Create); await file.CopyToAsync(fileStream); fileStream.Close(); return(localFilePath); }
public string SaveString(string path, string data, SaveFileOptions options = null) { var directoryName = Directory.GetParent(path).FullName; Directory.CreateDirectory(directoryName); System.IO.File.WriteAllText(path, data); return(path); }
public string SaveString(string path, string data, SaveFileOptions options = null) { System.IO.File.WriteAllText(path, data); if (options != null && options.SkipCloudBackup) { NSFileManager.SetSkipBackupAttribute(path, true); } return(path); }
/// <summary> /// Gets the output file by showing a save file dialog. /// </summary> /// <returns></returns> public static (bool dialogResult, string outputFileName) ShowGetOutputFileDialog() { var dlg = new SaveFileOptions(); dlg.AddFilter("*.html", "Html files (*.html)"); dlg.AddFilter("*.*", "All files (*.*)"); dlg.AddExtension = true; var dialogResult = Current.Gui.ShowSaveFileDialog(dlg); return(dialogResult, dlg.FileName); }
/// <summary> /// This opens the "Save as" dialog box to choose a basic file name for exporting. /// </summary> public void ChooseBasicFileNameAndPath() { var saveOptions = new SaveFileOptions(); saveOptions.AddFilter("*.*", "All Files (*.*)"); saveOptions.FilterIndex = 0; saveOptions.RestoreDirectory = true; if (Current.Gui.ShowSaveFileDialog(saveOptions)) { _view.BasicFileName = saveOptions.FileName; } }
/// <summary> /// Gets the output file by showing a save file dialog. /// </summary> /// <returns></returns> public static (bool dialogResult, string outputFileName) ShowGetOutputFileDialog() { var dlg = new SaveFileOptions(); dlg.AddFilter("*.shfbproj", "Sandcastle help file builder project (*.shfbproj)"); dlg.AddFilter("*.content", "Content files (*.content)"); dlg.AddFilter("*.*", "All files (*.*)"); dlg.AddExtension = true; var dialogResult = Current.Gui.ShowSaveFileDialog(dlg); return(dialogResult, dlg.FileName); }
/// <summary> /// Exports the <see cref="TextDocument"/> to a markdown file, showing first the file save dialog. /// </summary> /// <param name="document">The document to export.</param> public static void ExportShowDialog(TextDocument document) { var options = new MarkdownExportOptions(); var dlg = new SaveFileOptions(); dlg.AddFilter("*.md", "Markdown files (*.md)"); dlg.AddFilter("*.txt", "Text files (*.txt)"); dlg.AddFilter("*.*", "All files (*.*)"); dlg.AddExtension = true; if (true == Current.Gui.ShowSaveFileDialog(dlg)) { options.Export(document, dlg.FileName); } }
} // = new Units.DimensionfulQuantity(9.5, new Units.PrefixedUnit(Units.SIPrefix.Centi, Units.Length.Meter.Instance)); #endregion Properties /// <summary> /// Gets the output file by showing a save file dialog. /// </summary> /// <returns></returns> public static (bool dialogResult, string outputFileName) ShowGetOutputFileDialog(string oldFileName = null) { var dlg = new SaveFileOptions(); dlg.AddFilter("*.docx", "Docx files (*.docx)"); dlg.AddFilter("*.*", "All files (*.*)"); dlg.AddExtension = true; if (null != oldFileName) { dlg.InitialDirectory = System.IO.Path.GetDirectoryName(oldFileName); dlg.FileName = oldFileName; } var dialogResult = Current.Gui.ShowSaveFileDialog(dlg); return(dialogResult, dlg.FileName); }
public string ShowSaveFileDialog(SaveFileOptions options = null) { if (options == null) { options = new SaveFileOptions(); } var saveFileDialog = new Microsoft.Win32.SaveFileDialog(); saveFileDialog.AddExtension = options.AddExtension; saveFileDialog.CheckFileExists = options.CheckFileExists; saveFileDialog.CheckPathExists = options.CheckPathExists; saveFileDialog.DefaultExt = options.DefaultExt; saveFileDialog.DereferenceLinks = options.DereferenceLinks; saveFileDialog.Filter = options.Filter; saveFileDialog.FilterIndex = options.FilterIndex; saveFileDialog.InitialDirectory = options.InitialDirectory; saveFileDialog.RestoreDirectory = options.RestoreDirectory; saveFileDialog.Title = options.Title; saveFileDialog.ValidateNames = options.ValidateNames; saveFileDialog.FileName = options.DefaultFileName; saveFileDialog.CustomPlaces = options.CustomPlaces? .Select(path => new Microsoft.Win32.FileDialogCustomPlace(path)) .ToList(); var result = saveFileDialog.ShowDialog(); if (result == true) { return(saveFileDialog.FileName); } else { return(null); } }
static void SaveFile(SaveFileOptions options) { BGWorker.RulesFileName = options.SaveFilePath; BGWorker.SaveRules(); }
public override bool ShowSaveFileDialog(SaveFileOptions options) { var dlg = new SaveFileDialog(); dlg.Filter = GetFilterString(options); dlg.FilterIndex = options.FilterIndex; //dlg.Multiselect = options.Multiselect; if (options.Title != null) dlg.Title = options.Title; if (options.InitialDirectory != null) dlg.InitialDirectory = options.InitialDirectory; dlg.RestoreDirectory = options.RestoreDirectory; DialogResult r = dlg.ShowDialog(MainWindow); if (r == DialogResult.OK) { options.FileName = dlg.FileName; options.FileNames = dlg.FileNames; } else { options.FileName = null; options.FileNames = null; } return r == DialogResult.OK; }
public abstract bool ShowSaveFileDialog(SaveFileOptions options);
public override bool ShowSaveFileDialog(SaveFileOptions options) { if (InvokeRequired()) return (bool)MainWindowWpf.Dispatcher.Invoke((Func<SaveFileOptions, bool>)InternalShowSaveFileDialog, new object[] { options }); else return InternalShowSaveFileDialog(options); }
public string SaveBytes(string path, byte[] data, SaveFileOptions options = null) { Directory.CreateDirectory(Directory.GetParent(path).FullName); File.WriteAllBytes(path, data); return(path); }
public async Task <Models.Probe.FilesViewModels.UploadFileViewModel> SaveToProbe(IFormFile file, string siteName, string path, SaveFileOptions options = SaveFileOptions.RandomName, string accessToken = null) { string fileName = options == SaveFileOptions.RandomName ? Guid.NewGuid().ToString("N") + GetExtension(file.FileName) : file.FileName; if (accessToken == null) { accessToken = await _appsContainer.AccessToken(); } var result = await _filesService.UploadFileAsync(accessToken, siteName, path, file.OpenReadStream(), fileName, true); return(result); }
public async Task <AiurProtocol> SaveToProbe(IFormFile file, string siteName, string path, SaveFileOptions options = SaveFileOptions.RandomName, string accessToken = null, string name = "", bool deleteLocal = true) { string localFilePath = await _SaveLocally(file, options, name); if (accessToken == null) { accessToken = await _appsContainer.AccessToken(); } var result = await _filesService.UploadFileAsync(accessToken, siteName, path, localFilePath); if (deleteLocal) { File.Delete(localFilePath); } return(result); }
private bool InternalShowSaveFileDialog(SaveFileOptions options) { var dlg = new Microsoft.Win32.SaveFileDialog(); dlg.Filter = GetFilterString(options); dlg.FilterIndex = options.FilterIndex; //dlg.Multiselect = options.Multiselect; if (options.Title != null) dlg.Title = options.Title; if (options.InitialDirectory != null) dlg.InitialDirectory = options.InitialDirectory; dlg.RestoreDirectory = options.RestoreDirectory; dlg.OverwritePrompt = options.OverwritePrompt; dlg.AddExtension = options.AddExtension; if (true == dlg.ShowDialog(TopmostModalWindow)) { options.FileName = dlg.FileName; options.FileNames = dlg.FileNames; return true; } else { options.FileName = null; options.FileNames = null; return false; } }
public async Task <Models.Probe.FilesViewModels.UploadFileViewModel> SaveToProbe(IFormFile file, string siteName, string path, SaveFileOptions options, string accessToken = null) { string fileName = options == SaveFileOptions.RandomName ? Guid.NewGuid().ToString("N") + GetExtension(file.FileName) : file.FileName.Replace(" ", "_"); if (!new ValidFolderName().IsValid(fileName)) { throw new InvalidOperationException($"The file with name: '{fileName}' is invalid!"); } if (accessToken == null) { accessToken = await _appsContainer.AccessToken(); } var result = await _filesService.UploadFileAsync(accessToken, siteName, path, file.OpenReadStream(), fileName, true); return(result); }
public async Task <string> SaveToOSS(IFormFile file, int BucketId, int AliveDays, SaveFileOptions options = SaveFileOptions.RandomName, string AccessToken = null, string name = "", bool deleteLocal = true) { string localFilePath = await _SaveLocally(file, options, name); if (AccessToken == null) { AccessToken = await _appsContainer.AccessToken(); } var fileAddress = await _ossApiService.UploadFile(AccessToken, BucketId, localFilePath, AliveDays); if (deleteLocal) { File.Delete(localFilePath); } return(fileAddress.Path); }
public static void ExportPLSCalibration(Altaxo.Data.DataTable table) { // quest the number of factors to export IntegerValueInputController ivictrl = new IntegerValueInputController(1, "Please choose number of factors to export (>0):"); ivictrl.Validator = new IntegerValueInputController.ZeroOrPositiveIntegerValidator(); if (!Current.Gui.ShowDialog(ivictrl, "Number of factors", false)) return; // quest the filename SaveFileOptions options = new SaveFileOptions(); options.AddFilter("*.xml", "Xml files (*.xml)"); options.FilterIndex = 0; if (!Current.Gui.ShowSaveFileDialog(options)) return; PredictionModelExporter exporter = new PredictionModelExporter(table, ivictrl.EnteredContents); exporter.Export(options.FileName); }