Skip to content

Instantly share code, notes, and snippets.

@Fhernd
Created July 21, 2015 14:30
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/7674e3595381167a6688 to your computer and use it in GitHub Desktop.
Save Fhernd/7674e3595381167a6688 to your computer and use it in GitHub Desktop.
Creación de archivo con nombre aleatorio.
// OrtizOL - xCSw - http://ortizol.blogspot.com
using System;
using System.IO;
namespace Receta.CSharp.R0521
{
public class CreacionArchivoNombreAleatorio
{
public static void Main()
{
Console.WriteLine(Environment.NewLine);
// Creación de nombre de archivo aleatorio:
string archivoTemporal = Path.GetRandomFileName();
Console.WriteLine("Nombre del archivo a crear: {0}", archivoTemporal);
// Creación del archivo:
using (FileStream fs = new FileStream(archivoTemporal, FileMode.OpenOrCreate))
{
// Escritura de datos...
}
Console.WriteLine("Presione Enter para eliminar el archivo temporal.");
Console.ReadLine();
File.Delete(archivoTemporal);
Console.WriteLine(Environment.NewLine);
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment