Created
July 18, 2015 22:44
-
-
Save Fhernd/10ff52c716aca66362b6 to your computer and use it in GitHub Desktop.
Demostración de creación de archivos temporales en C#.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// OrtizOL - xCSw - http://ortizol.blogspot.com | |
using System; | |
using System.IO; | |
namespace Receta.CSharp.R0515 | |
{ | |
public class CreacionArchivoTemporal | |
{ | |
public static void Main() | |
{ | |
Console.WriteLine(Environment.NewLine); | |
// Crea un archivo temporal y obtiene | |
// su ruta: | |
string archivoTemp = Path.GetTempFileName(); | |
Console.WriteLine("Nuevo archivo temporal: {0}", archivoTemp); | |
using (FileStream fs = new FileStream(archivoTemp, FileMode.Open)) | |
{ | |
// Escritura de datos de usuario o de aplicación... | |
} | |
// Borra el archivo temporal: | |
Console.WriteLine("Presione Enter para borrar el archivo temporal."); | |
Console.ReadLine(); | |
File.Delete(archivoTemp); | |
Console.WriteLine(Environment.NewLine); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment