Skip to content

Instantly share code, notes, and snippets.

@Fhernd
Created July 20, 2015 16:08
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/e896f2e83ecaca311213 to your computer and use it in GitHub Desktop.
Save Fhernd/e896f2e83ecaca311213 to your computer and use it in GitHub Desktop.
Uso de almacenamiento aislado en C#.
// 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