Created
July 20, 2015 16:08
-
-
Save Fhernd/e896f2e83ecaca311213 to your computer and use it in GitHub Desktop.
Uso de almacenamiento aislado 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; | |
using System.IO.IsolatedStorage; | |
namespace Receta.CSharp.R0518 | |
{ | |
public class AlmacenamientoAislado | |
{ | |
public static void Main() | |
{ | |
Console.WriteLine(Environment.NewLine); | |
// Creación de almacenamiento aislado para el usuario actual: | |
using (IsolatedStorageFile almacenamiento = IsolatedStorageFile.GetUserStoreForAssembly()) | |
{ | |
// Creación de una carpeta en la raíz: | |
almacenamiento.CreateDirectory("Assets"); | |
// Creación de archivo: | |
using (Stream fs = new IsolatedStorageFileStream("Reportes.txt", FileMode.Create, almacenamiento)) | |
{ | |
StreamWriter sw = new StreamWriter(fs); | |
// Escritura de datos: | |
sw.WriteLine("11:02 Monday, July 20, 2015"); | |
sw.Flush(); | |
} | |
Console.WriteLine("Tamaño actual: {0}", almacenamiento.UsedSize.ToString()); | |
Console.WriteLine("Ambito: {0}", almacenamiento.Scope.ToString()); | |
Console.WriteLine (); | |
Console.WriteLine("Archivos existentes:"); | |
string[] archivos = almacenamiento.GetFileNames("*.*"); | |
foreach(string archivo in archivos) | |
{ | |
Console.WriteLine("\t{0}", archivo); | |
} | |
} | |
Console.WriteLine(Environment.NewLine); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment