Skip to content

Instantly share code, notes, and snippets.

@Fhernd
Created July 18, 2015 22:44
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Fhernd/10ff52c716aca66362b6 to your computer and use it in GitHub Desktop.
Save Fhernd/10ff52c716aca66362b6 to your computer and use it in GitHub Desktop.
Demostración de creación de archivos temporales en C#.
// 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