Created
July 21, 2015 14:30
-
-
Save Fhernd/7674e3595381167a6688 to your computer and use it in GitHub Desktop.
Creación de archivo con nombre aleatorio.
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.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