/// <summary> /// Graba los datos /// </summary> protected override void Save() { if (ValidateData()) { string targetPath = System.IO.Path.Combine(PathTarget, Name); string fileName = HelperFiles.CombineFileName(targetPath, HelperFiles.Normalize(Name), ProjectsDefinition.SelectedItem.Project.Extension); ProjectModel project; // Crea el directorio HelperFiles.MakePath(targetPath); // Crea el proyecto (después de crear el directorio) project = new ProjectModel(_solution, ProjectsDefinition.SelectedItem.Project, fileName); // Crea el archivo de proyecto (vacío) HelperFiles.SaveTextFile(fileName, ""); // Añade el proyecto a la solución if (_folder == null) { _solution.Projects.Add(project); } else { _folder.Projects.Add(project); } // Crea el proyecto SourceEditorViewModel.Instance.MessagesController.OpenFile(project.Definition, project, true); // Cierra el formulario RaiseEventClose(true); } }
/// <summary> /// Graba un archivo de texto /// </summary> internal void Save(string fileName, string content) { // Crea el directorio de salida HelperFiles.MakePath(Path); // Graba el contenido HelperFiles.SaveTextFile(System.IO.Path.Combine(Path, fileName), content); }
/// <summary> /// Sube un texto /// </summary> internal void UploadText(string text) { string fileName = GetFileName("output.txt", true); // Graba el archivo HelperFiles.SaveTextFile(fileName, text); // ... y lo sube if (IsUrl(Manager.UrlDownload)) { UploadFile(Manager.UrlDownload.GetUrl(), fileName); HelperFiles.KillFile(fileName); } }
/// <summary> /// Graba un texto en un archivo con codificación UTF8 pero sin los caracteres iniciales de BOM. /// </summary> /// <remarks> /// Databricks no reconoce en los notebook los archivos de texto UTF8 que se graban con los caracteres iniciales /// que indican que el archivo es UTF8, por eso se tiene que indicar en la codificación que se omitan estos caracteres /// <see cref="https://stackoverflow.com/questions/2502990/create-text-file-without-bom"/> /// </remarks> private void SaveFileWithoutBom(string fileName, string content) { HelperFiles.SaveTextFile(fileName, content, new System.Text.UTF8Encoding(false)); }