IsolatedStorageFileStream Clase
Definición
Importante
Parte de la información hace referencia a la versión preliminar del producto, que puede haberse modificado sustancialmente antes de lanzar la versión definitiva. Microsoft no otorga ninguna garantía, explícita o implícita, con respecto a la información proporcionada aquí.
Expone un archivo dentro del almacenamiento aislado.
public ref class IsolatedStorageFileStream : System::IO::Stream
public ref class IsolatedStorageFileStream : System::IO::FileStream
public class IsolatedStorageFileStream : System.IO.Stream
public class IsolatedStorageFileStream : System.IO.FileStream
[System.Runtime.InteropServices.ComVisible(true)]
public class IsolatedStorageFileStream : System.IO.FileStream
type IsolatedStorageFileStream = class
inherit Stream
type IsolatedStorageFileStream = class
inherit FileStream
[<System.Runtime.InteropServices.ComVisible(true)>]
type IsolatedStorageFileStream = class
inherit FileStream
Public Class IsolatedStorageFileStream
Inherits Stream
Public Class IsolatedStorageFileStream
Inherits FileStream
- Herencia
- Herencia
- Atributos
Ejemplos
En la siguiente aplicación de consola se muestra cómo puede usar IsolatedStorageFile y IsolatedStorageFileStream escribir datos en un archivo de almacenamiento aislado. Se solicita al usuario que inicie sesión. Si el usuario es un nuevo usuario, una dirección URL de noticias y una dirección URL deportiva se registran como preferencias personales en Almacenamiento aislado. Si el usuario es un usuario que devuelve, se muestran las preferencias actuales del usuario. Los ejemplos de código que se usan en este espacio de nombres se presentan en el contexto de esta aplicación de ejemplo. Puede usar la utilidad Storeadm.exe (Herramienta de almacenamiento aislado) para enumerar y quitar los archivos de almacenamiento aislado que se crean con esta aplicación de consola.
// This sample demonstrates methods of classes found in the System.IO IsolatedStorage namespace.
using System;
using System.IO;
using System.IO.IsolatedStorage;
using System.Security.Policy;
using Microsoft.Win32.SafeHandles;
[assembly: CLSCompliantAttribute(true)]
class ConsoleApp
{
[STAThread]
static void Main(string[] args)
{
// Prompt the user for their username.
Console.WriteLine("Login:");
// Does no error checking.
LoginPrefs lp = new LoginPrefs(Console.ReadLine());
if (lp.NewPrefs)
{
Console.WriteLine("Please set preferences for a new user.");
GatherInfoFromUser(lp);
// Write the new preferences to storage.
double percentUsed = lp.SetPrefsForUser();
Console.WriteLine("Your preferences have been written. Current space used is " + percentUsed.ToString() + " %");
}
else
{
Console.WriteLine("Welcome back.");
Console.WriteLine("Your preferences have expired, please reset them.");
GatherInfoFromUser(lp);
lp.SetNewPrefsForUser();
Console.WriteLine("Your news site has been set to {0}\n and your sports site has been set to {1}.", lp.NewsUrl, lp.SportsUrl);
}
lp.GetIsoStoreInfo();
Console.WriteLine("Enter 'd' to delete the IsolatedStorage files and exit, or press any other key to exit without deleting files.");
string consoleInput = Console.ReadLine();
if (consoleInput.ToLower() == "d")
{
lp.DeleteFiles();
lp.DeleteDirectories();
}
}
static void GatherInfoFromUser(LoginPrefs lp)
{
Console.WriteLine("Please enter the URL of your news site.");
lp.NewsUrl = Console.ReadLine();
Console.WriteLine("Please enter the URL of your sports site.");
lp.SportsUrl = Console.ReadLine();
}
}
public class LoginPrefs
{
public LoginPrefs(string myUserName)
{
userName = myUserName;
myNewPrefs = GetPrefsForUser();
}
string userName;
string myNewsUrl;
public string NewsUrl
{
get { return myNewsUrl; }
set { myNewsUrl = value; }
}
string mySportsUrl;
public string SportsUrl
{
get { return mySportsUrl; }
set { mySportsUrl = value; }
}
bool myNewPrefs;
public bool NewPrefs
{
get { return myNewPrefs; }
}
private bool GetPrefsForUser()
{
try
{
// Retrieve an IsolatedStorageFile for the current Domain and Assembly.
IsolatedStorageFile isoFile =
IsolatedStorageFile.GetStore(IsolatedStorageScope.User |
IsolatedStorageScope.Assembly |
IsolatedStorageScope.Domain,
null,
null);
IsolatedStorageFileStream isoStream =
new IsolatedStorageFileStream("substituteUsername",
System.IO.FileMode.Open,
System.IO.FileAccess.Read,
System.IO.FileShare.Read);
// The code executes to this point only if a file corresponding to the username exists.
// Though you can perform operations on the stream, you cannot get a handle to the file.
try
{
SafeFileHandle aFileHandle = isoStream.SafeFileHandle;
Console.WriteLine("A pointer to a file handle has been obtained. "
+ aFileHandle.ToString() + " "
+ aFileHandle.GetHashCode());
}
catch (Exception e)
{
// Handle the exception.
Console.WriteLine("Expected exception");
Console.WriteLine(e);
}
StreamReader reader = new StreamReader(isoStream);
// Read the data.
this.NewsUrl = reader.ReadLine();
this.SportsUrl = reader.ReadLine();
reader.Close();
isoFile.Close();
return false;
}
catch (System.IO.FileNotFoundException)
{
// Expected exception if a file cannot be found. This indicates that we have a new user.
return true;
}
}
public bool GetIsoStoreInfo()
{
// Get a User store with type evidence for the current Domain and the Assembly.
IsolatedStorageFile isoFile = IsolatedStorageFile.GetStore(IsolatedStorageScope.User |
IsolatedStorageScope.Assembly |
IsolatedStorageScope.Domain,
typeof(System.Security.Policy.Url),
typeof(System.Security.Policy.Url));
String[] dirNames = isoFile.GetDirectoryNames("*");
String[] fileNames = isoFile.GetFileNames("*");
// List directories currently in this Isolated Storage.
if (dirNames.Length > 0)
{
for (int i = 0; i < dirNames.Length; ++i)
{
Console.WriteLine("Directory Name: " + dirNames[i]);
}
}
// List the files currently in this Isolated Storage.
// The list represents all users who have personal preferences stored for this application.
if (fileNames.Length > 0)
{
for (int i = 0; i < fileNames.Length; ++i)
{
Console.WriteLine("File Name: " + fileNames[i]);
}
}
isoFile.Close();
return true;
}
public double SetPrefsForUser()
{
try
{
IsolatedStorageFile isoFile;
isoFile = IsolatedStorageFile.GetUserStoreForDomain();
// Open or create a writable file.
IsolatedStorageFileStream isoStream =
new IsolatedStorageFileStream(this.userName,
FileMode.OpenOrCreate,
FileAccess.Write,
isoFile);
StreamWriter writer = new StreamWriter(isoStream);
writer.WriteLine(this.NewsUrl);
writer.WriteLine(this.SportsUrl);
// Calculate the amount of space used to record the user's preferences.
double d = isoFile.CurrentSize / isoFile.MaximumSize;
Console.WriteLine("CurrentSize = " + isoFile.CurrentSize.ToString());
Console.WriteLine("MaximumSize = " + isoFile.MaximumSize.ToString());
// StreamWriter.Close implicitly closes isoStream.
writer.Close();
isoFile.Dispose();
isoFile.Close();
return d;
}
catch (IsolatedStorageException ex)
{
// Add code here to handle the exception.
Console.WriteLine(ex);
return 0.0;
}
}
public void DeleteFiles()
{
try
{
IsolatedStorageFile isoFile = IsolatedStorageFile.GetStore(IsolatedStorageScope.User |
IsolatedStorageScope.Assembly |
IsolatedStorageScope.Domain,
typeof(System.Security.Policy.Url),
typeof(System.Security.Policy.Url));
String[] dirNames = isoFile.GetDirectoryNames("*");
String[] fileNames = isoFile.GetFileNames("*");
// List the files currently in this Isolated Storage.
// The list represents all users who have personal
// preferences stored for this application.
if (fileNames.Length > 0)
{
for (int i = 0; i < fileNames.Length; ++i)
{
// Delete the files.
isoFile.DeleteFile(fileNames[i]);
}
// Confirm that no files remain.
fileNames = isoFile.GetFileNames("*");
}
}
catch (Exception e)
{
Console.WriteLine(e.ToString());
}
}
// This method deletes directories in the specified Isolated Storage, after first
// deleting the files they contain. In this example, the Archive directory is deleted.
// There should be no other directories in this Isolated Storage.
public void DeleteDirectories()
{
try
{
IsolatedStorageFile isoFile = IsolatedStorageFile.GetStore(IsolatedStorageScope.User |
IsolatedStorageScope.Assembly |
IsolatedStorageScope.Domain,
typeof(System.Security.Policy.Url),
typeof(System.Security.Policy.Url));
String[] dirNames = isoFile.GetDirectoryNames("*");
String[] fileNames = isoFile.GetFileNames("Archive\\*");
// Delete all the files currently in the Archive directory.
if (fileNames.Length > 0)
{
for (int i = 0; i < fileNames.Length; ++i)
{
// Delete the files.
isoFile.DeleteFile("Archive\\" + fileNames[i]);
}
// Confirm that no files remain.
fileNames = isoFile.GetFileNames("Archive\\*");
}
if (dirNames.Length > 0)
{
for (int i = 0; i < dirNames.Length; ++i)
{
// Delete the Archive directory.
}
}
dirNames = isoFile.GetDirectoryNames("*");
isoFile.Remove();
}
catch (Exception e)
{
Console.WriteLine(e.ToString());
}
}
public double SetNewPrefsForUser()
{
try
{
byte inputChar;
IsolatedStorageFile isoFile = IsolatedStorageFile.GetStore(IsolatedStorageScope.User |
IsolatedStorageScope.Assembly |
IsolatedStorageScope.Domain,
typeof(System.Security.Policy.Url),
typeof(System.Security.Policy.Url));
// If this is not a new user, archive the old preferences and
// overwrite them using the new preferences.
if (!this.myNewPrefs)
{
if (isoFile.GetDirectoryNames("Archive").Length == 0)
{
isoFile.CreateDirectory("Archive");
}
else
{
IsolatedStorageFileStream source =
new IsolatedStorageFileStream(this.userName, FileMode.OpenOrCreate,
isoFile);
// This is the stream from which data will be read.
Console.WriteLine("Is the source file readable? " + (source.CanRead ? "true" : "false"));
Console.WriteLine("Creating new IsolatedStorageFileStream for Archive.");
// Open or create a writable file.
IsolatedStorageFileStream target =
new IsolatedStorageFileStream("Archive\\ " + this.userName,
FileMode.OpenOrCreate,
FileAccess.Write,
FileShare.Write,
isoFile);
Console.WriteLine("Is the target file writable? " + (target.CanWrite ? "true" : "false"));
// Stream the old file to a new file in the Archive directory.
if (source.IsAsync && target.IsAsync)
{
// IsolatedStorageFileStreams cannot be asynchronous. However, you
// can use the asynchronous BeginRead and BeginWrite functions
// with some possible performance penalty.
Console.WriteLine("IsolatedStorageFileStreams cannot be asynchronous.");
}
else
{
Console.WriteLine("Writing data to the new file.");
while (source.Position < source.Length)
{
inputChar = (byte)source.ReadByte();
target.WriteByte(inputChar);
}
// Determine the size of the IsolatedStorageFileStream
// by checking its Length property.
Console.WriteLine("Total Bytes Read: " + source.Length);
}
// After you have read and written to the streams, close them.
target.Close();
source.Close();
}
}
// Open or create a writable file with a maximum size of 10K.
IsolatedStorageFileStream isoStream =
new IsolatedStorageFileStream(this.userName,
FileMode.OpenOrCreate,
FileAccess.Write,
FileShare.Write,
10240,
isoFile);
isoStream.Position = 0; // Position to overwrite the old data.
StreamWriter writer = new StreamWriter(isoStream);
// Update the data based on the new inputs.
writer.WriteLine(this.NewsUrl);
writer.WriteLine(this.SportsUrl);
// Calculate the amount of space used to record this user's preferences.
double d = isoFile.CurrentSize / isoFile.MaximumSize;
Console.WriteLine("CurrentSize = " + isoFile.CurrentSize.ToString());
Console.WriteLine("MaximumSize = " + isoFile.MaximumSize.ToString());
// StreamWriter.Close implicitly closes isoStream.
writer.Close();
isoFile.Close();
return d;
}
catch (Exception e)
{
Console.WriteLine(e.ToString());
return 0.0;
}
}
}
'This sample demonstrates methods of classes found in the System.IO IsolatedStorage namespace.
Imports System.IO
Imports System.IO.IsolatedStorage
Imports System.Security.Policy
Imports Microsoft.Win32.SafeHandles
Imports System.Security.Permissions
Namespace ISOCS
_
Class ConsoleApp
<STAThread()> _
Overloads Shared Sub Main(ByVal args() As String)
' Prompt the user for their username.
Console.WriteLine("Enter your login ID:")
' Does no error checking.
Dim lp As New LoginPrefs(Console.ReadLine())
If lp.NewPrefs Then
Console.WriteLine("Please set preferences for a new user.")
GatherInfoFromUser(lp)
' Write the new preferences to storage.
Dim percentUsed As Double = lp.SetPrefsForUser()
Console.WriteLine(("Your preferences have been written. Current space used is " & percentUsed.ToString() & " %"))
Else
Console.WriteLine("Welcome back.")
Console.WriteLine("Your preferences have expired, please reset them.")
GatherInfoFromUser(lp)
lp.SetNewPrefsForUser()
Console.WriteLine("Your news site has been set to {0}" & ControlChars.Cr & " and your sports site has been set to {1}.", lp.NewsUrl, lp.SportsUrl)
End If
lp.GetIsoStoreInfo()
Console.WriteLine("Enter 'd' to delete the IsolatedStorage files and exit, or press any other key to exit without deleting files.")
Dim consoleInput As String = Console.ReadLine()
If consoleInput.ToLower() = "d" Then
lp.DeleteFiles()
lp.DeleteDirectories()
End If
End Sub
Shared Sub GatherInfoFromUser(ByVal lp As LoginPrefs)
Console.WriteLine("Please enter the URL of your news site.")
lp.NewsUrl = Console.ReadLine()
Console.WriteLine("Please enter the URL of your sports site.")
lp.SportsUrl = Console.ReadLine()
End Sub
End Class
_
<SecurityPermissionAttribute(SecurityAction.Demand, Flags:=SecurityPermissionFlag.UnmanagedCode)> _
Public Class LoginPrefs
Public Sub New(ByVal myUserName As String)
userName = myUserName
myNewPrefs = GetPrefsForUser()
End Sub
Private userName As String
Private myNewsUrl As String
Public Property NewsUrl() As String
Get
Return myNewsUrl
End Get
Set(ByVal Value As String)
myNewsUrl = Value
End Set
End Property
Private mySportsUrl As String
Public Property SportsUrl() As String
Get
Return mySportsUrl
End Get
Set(ByVal Value As String)
mySportsUrl = Value
End Set
End Property
Private myNewPrefs As Boolean
Public ReadOnly Property NewPrefs() As Boolean
Get
Return myNewPrefs
End Get
End Property
Private Function GetPrefsForUser() As Boolean
Try
' Retrieve an IsolatedStorageFile for the current Domain and Assembly.
Dim isoFile As IsolatedStorageFile = _
IsolatedStorageFile.GetStore(IsolatedStorageScope.User _
Or IsolatedStorageScope.Assembly _
Or IsolatedStorageScope.Domain, Nothing, Nothing)
Dim isoStream As New IsolatedStorageFileStream("substituteUsername", System.IO.FileMode.Open, _
System.IO.FileAccess.Read, System.IO.FileShare.Read)
' farThe code executes to this point only if a file corresponding to the username exists.
' Though you can perform operations on the stream, you cannot get a handle to the file.
Try
Dim aFileHandle As SafeFileHandle = isoStream.SafeFileHandle
Console.WriteLine(("A pointer to a file handle has been obtained. " & aFileHandle.ToString() & " " & aFileHandle.GetHashCode()))
Catch ex As Exception
' Handle the exception.
Console.WriteLine("Expected exception")
Console.WriteLine(ex.ToString())
End Try
Dim reader As New StreamReader(isoStream)
' Read the data.
Me.NewsUrl = reader.ReadLine()
Me.SportsUrl = reader.ReadLine()
reader.Close()
isoFile.Close()
Return False
Catch ex As System.IO.FileNotFoundException
' Expected exception if a file cannot be found. This indicates that we have a new user.
Return True
End Try
End Function 'GetPrefsForUser
Public Function GetIsoStoreInfo() As Boolean
Try
'Get a User store with type evidence for the current Domain and the Assembly.
Dim isoFile As IsolatedStorageFile = _
IsolatedStorageFile.GetStore(IsolatedStorageScope.User Or _
IsolatedStorageScope.Assembly Or IsolatedStorageScope.Domain, _
GetType(System.Security.Policy.Url), GetType(System.Security.Policy.Url))
Dim dirNames As String() = isoFile.GetDirectoryNames("*")
Dim fileNames As String() = isoFile.GetFileNames("*")
Dim name As String
' List directories currently in this Isolated Storage.
If dirNames.Length > 0 Then
For Each name In dirNames
Console.WriteLine("Directory Name: " & name)
Next name
End If
' List the files currently in this Isolated Storage.
' The list represents all users who have personal preferences stored for this application.
If fileNames.Length > 0 Then
For Each name In fileNames
Console.WriteLine("File Name: " & name)
Next name
End If
isoFile.Close()
Return True
Catch ex As Exception
Console.WriteLine(ex.ToString())
End Try
End Function 'GetIsoStoreInfo
Public Function SetPrefsForUser() As Double
Try
Dim isoFile As IsolatedStorageFile
isoFile = IsolatedStorageFile.GetUserStoreForDomain()
' Open or create a writable file.
Dim isoStream As New IsolatedStorageFileStream(Me.userName, FileMode.OpenOrCreate, _
FileAccess.Write, isoFile)
Dim writer As New StreamWriter(isoStream)
writer.WriteLine(Me.NewsUrl)
writer.WriteLine(Me.SportsUrl)
' Calculate the amount of space used to record the user's preferences.
Dim d As Double = Convert.ToDouble(isoFile.CurrentSize) / Convert.ToDouble(isoFile.MaximumSize)
Console.WriteLine(("CurrentSize = " & isoFile.CurrentSize.ToString()))
Console.WriteLine(("MaximumSize = " & isoFile.MaximumSize.ToString()))
' StreamWriter.Close implicitly closes isoStream.
writer.Close()
isoFile.Dispose()
isoFile.Close()
Return d
Catch ex As Exception
' Add code here to handle the exception.
Console.WriteLine(ex)
Return 0.0
End Try
End Function 'SetPrefsForUser
Public Sub DeleteFiles()
Try
Dim isoFile As IsolatedStorageFile = IsolatedStorageFile.GetStore(IsolatedStorageScope.User Or _
IsolatedStorageScope.Assembly Or IsolatedStorageScope.Domain, _
GetType(System.Security.Policy.Url), GetType(System.Security.Policy.Url))
Dim name As String
Dim dirNames As String() = isoFile.GetDirectoryNames("*")
Dim fileNames As String() = isoFile.GetFileNames("*")
' List the files currently in this Isolated Storage.
' The list represents all users who have personal
' preferences stored for this application.
If fileNames.Length > 0 Then
For Each name In fileNames
' Delete the files.
isoFile.DeleteFile(name)
Next name
'Confirm no files are left.
fileNames = isoFile.GetFileNames("*")
End If
Catch ex As Exception
Console.WriteLine(ex.ToString())
End Try
End Sub
' This method deletes directories in the specified Isolated Storage, after first
' deleting the files they contain. In this example, the Archive directory is deleted.
' There should be no other directories in this Isolated Storage.
Public Sub DeleteDirectories()
Try
Dim isoFile As IsolatedStorageFile = IsolatedStorageFile.GetStore(IsolatedStorageScope.User _
Or IsolatedStorageScope.Assembly Or IsolatedStorageScope.Domain, _
GetType(System.Security.Policy.Url), GetType(System.Security.Policy.Url))
Dim name As String
Dim dirNames As String() = isoFile.GetDirectoryNames("*")
Dim fileNames As String() = isoFile.GetFileNames("Archive\*")
' Delete all the files currently in the Archive directory.
If fileNames.Length > 0 Then
For Each name In fileNames
isoFile.DeleteFile(("Archive\" & name))
Next name
'Confirm no files are left.
fileNames = isoFile.GetFileNames("Archive\*")
End If
If dirNames.Length > 0 Then
For Each name In dirNames
' Delete the Archive directory.
isoFile.DeleteDirectory(name)
Next name
End If
dirNames = isoFile.GetDirectoryNames("*")
isoFile.Remove()
Catch ex As Exception
Console.WriteLine(ex.ToString())
End Try
End Sub
Public Function SetNewPrefsForUser() As Double
Try
Dim inputChar As Byte
Dim isoFile As IsolatedStorageFile = IsolatedStorageFile.GetStore(IsolatedStorageScope.User Or _
IsolatedStorageScope.Assembly Or IsolatedStorageScope.Domain, _
GetType(System.Security.Policy.Url), GetType(System.Security.Policy.Url))
' If this is not a new user, archive the old preferences and
' overwrite them using the new preferences.
If Not Me.myNewPrefs Then
If isoFile.GetDirectoryNames("Archive").Length = 0 Then
isoFile.CreateDirectory("Archive")
Else
Dim source As New IsolatedStorageFileStream(Me.userName, FileMode.OpenOrCreate, isoFile)
Dim canWrite, canRead As Boolean
' This is the stream from which data will be read.
If source.CanRead Then canRead = True Else canRead = False
Console.WriteLine("Is the source file readable? " & canRead)
Console.WriteLine("Creating new IsolatedStorageFileStream for Archive.")
' Open or create a writable file.
Dim target As New IsolatedStorageFileStream("Archive\ " & Me.userName, _
FileMode.OpenOrCreate, FileAccess.Write, FileShare.Write, isoFile)
' This is the stream to which data will be written.
If target.CanWrite Then canWrite = True Else canWrite = False
Console.WriteLine("Is the target file writable? " & canWrite)
target.SetLength(0) 'rewind the target file
' Stream the old file to a new file in the Archive directory.
If source.IsAsync And target.IsAsync Then
' IsolatedStorageFileStreams cannot be asynchronous. However, you
' can use the asynchronous BeginRead and BeginWrite functions
' with some possible performance penalty.
Console.WriteLine("IsolatedStorageFileStreams cannot be asynchronous.")
Else
Console.WriteLine("Writing data to the new file.")
While source.Position < source.Length
inputChar = CByte(source.ReadByte())
target.WriteByte(inputChar)
End While
' Determine the size of the IsolatedStorageFileStream
' by checking its Length property.
Console.WriteLine(("Total Bytes Read: " & source.Length))
End If
' After you have read and written to the streams, close them.
target.Close()
source.Close()
End If
End If
' Open or create a writable file with a maximum size of 10K.
Dim isoStream As New IsolatedStorageFileStream(Me.userName, FileMode.OpenOrCreate, _
FileAccess.Write, FileShare.Write, 10240, isoFile)
isoStream.SetLength(0) 'Position to overwrite the old data.
Dim writer As New StreamWriter(isoStream)
' Update the data based on the new inputs.
writer.WriteLine(Me.NewsUrl)
writer.WriteLine(Me.SportsUrl)
' Calculate the amount of space used to record this user's preferences.
Dim d As Double = Convert.ToDouble(isoFile.CurrentSize) / Convert.ToDouble(isoFile.MaximumSize)
Console.WriteLine(("CurrentSize = " & isoFile.CurrentSize.ToString()))
Console.WriteLine(("MaximumSize = " & isoFile.MaximumSize.ToString()))
' StreamWriter.Close implicitly closes isoStream.
writer.Close()
isoFile.Close()
Return d
Catch ex As Exception
Console.WriteLine(ex.ToString())
Return 0.0
End Try
End Function 'SetNewPrefsForUser
End Class
End Namespace 'ISOCS
Comentarios
Use esta clase para leer, escribir y crear archivos en el almacenamiento aislado.
Dado que esta clase extiende FileStream, puede usar una instancia de en la mayoría de IsolatedStorageFileStream las situaciones en las que se podría usar un FileStream objeto , como para construir o StreamReaderStreamWriter.
Este tipo implementa la IDisposable interfaz . Cuando haya terminado de usar el tipo, debe eliminarlo directa o indirectamente. Para eliminar el tipo directamente, llame a su método Dispose en un bloque try/catch. Para eliminarlo indirectamente, use una construcción de lenguaje como using (en C#) o Using (en Visual Basic). Para obtener más información, vea la sección "Using an Object that Implements IDisposable" (Usar un objeto que implementa IDisposable) en el tema de interfaz IDisposable .
Constructores
| Nombre | Description |
|---|---|
| IsolatedStorageFileStream(String, FileMode, FileAccess, FileShare, Int32, IsolatedStorageFile) |
Inicializa una nueva instancia de la IsolatedStorageFileStream clase que da acceso al archivo designado por |
| IsolatedStorageFileStream(String, FileMode, FileAccess, FileShare, Int32) |
Inicializa una nueva instancia de la IsolatedStorageFileStream clase que proporciona acceso al archivo designado por |
| IsolatedStorageFileStream(String, FileMode, FileAccess, FileShare, IsolatedStorageFile) |
Inicializa una nueva instancia de la IsolatedStorageFileStream clase que da acceso al archivo designado por |
| IsolatedStorageFileStream(String, FileMode, FileAccess, FileShare) |
Inicializa una nueva instancia de la IsolatedStorageFileStream clase que proporciona acceso al archivo designado por |
| IsolatedStorageFileStream(String, FileMode, FileAccess, IsolatedStorageFile) |
Inicializa una nueva instancia de la IsolatedStorageFileStream clase que da acceso al archivo designado por |
| IsolatedStorageFileStream(String, FileMode, FileAccess) |
Inicializa una nueva instancia de la IsolatedStorageFileStream clase que proporciona acceso al archivo designado por |
| IsolatedStorageFileStream(String, FileMode, IsolatedStorageFile) |
Inicializa una nueva instancia de la IsolatedStorageFileStream clase que proporciona acceso al archivo designado por |
| IsolatedStorageFileStream(String, FileMode) |
Inicializa una nueva instancia de un IsolatedStorageFileStream objeto que proporciona acceso al archivo designado por |
Propiedades
| Nombre | Description |
|---|---|
| CanRead |
Obtiene un valor booleano que indica si se puede leer el archivo. |
| CanSeek |
Obtiene un valor booleano que indica si se admiten operaciones de búsqueda. |
| CanTimeout |
Obtiene un valor que determina si la secuencia actual puede agotar el tiempo de espera. (Heredado de Stream) |
| CanWrite |
Obtiene un valor booleano que indica si puede escribir en el archivo. |
| Handle |
Obsoletos.
Obsoletos.
Obsoletos.
Obtiene el identificador de archivo del archivo que el objeto actual IsolatedStorageFileStream encapsula. No se permite tener acceso a esta propiedad en un IsolatedStorageFileStream objeto y produce una IsolatedStorageExceptionexcepción . |
| IsAsync |
Obtiene un valor booleano que indica si el IsolatedStorageFileStream objeto se abrió de forma asincrónica o sincrónica. |
| Length |
Obtiene la longitud del IsolatedStorageFileStream objeto . |
| Name |
Obtiene la ruta de acceso absoluta del archivo abierto en . |
| Position |
Obtiene o establece la posición actual del objeto actual IsolatedStorageFileStream . |
| ReadTimeout |
Obtiene o establece un valor, en milisegundos, que determina cuánto tiempo intentará leer la secuencia antes de que se agote el tiempo de espera. (Heredado de Stream) |
| SafeFileHandle |
Obtiene un SafeFileHandle objeto que representa el identificador de archivo del sistema operativo para el archivo que el objeto actual IsolatedStorageFileStream encapsula. |
| WriteTimeout |
Obtiene o establece un valor, en milisegundos, que determina cuánto tiempo intentará escribir la secuencia antes de que se agote el tiempo de espera. (Heredado de Stream) |
Métodos
| Nombre | Description |
|---|---|
| BeginRead(Byte[], Int32, Int32, AsyncCallback, Object) |
Comienza una lectura asincrónica. |
| BeginWrite(Byte[], Int32, Int32, AsyncCallback, Object) |
Comienza una escritura asincrónica. |
| Close() |
Libera los recursos asociados al IsolatedStorageFileStream objeto . |
| CopyTo(Stream, Int32) |
Lee los bytes de la secuencia actual y los escribe en otra secuencia mediante un tamaño de búfer especificado. Ambas posiciones de secuencias están avanzadas por el número de bytes copiados. (Heredado de Stream) |
| CopyTo(Stream, Int32) |
Lee los bytes de la secuencia actual y los escribe en otra secuencia mediante un tamaño de búfer especificado. Ambas posiciones de secuencias están avanzadas por el número de bytes copiados. (Heredado de FileStream) |
| CopyTo(Stream) |
Lee los bytes de la secuencia actual y los escribe en otra secuencia. Ambas posiciones de secuencias están avanzadas por el número de bytes copiados. (Heredado de Stream) |
| CopyToAsync(Stream, CancellationToken) |
Lee asincrónicamente los bytes de la secuencia actual y los escribe en otra secuencia, mediante un token de cancelación especificado. Ambas posiciones de secuencias están avanzadas por el número de bytes copiados. (Heredado de Stream) |
| CopyToAsync(Stream, Int32, CancellationToken) |
Lee asincrónicamente los bytes de la secuencia actual y los escribe en otra secuencia, mediante un tamaño de búfer y un token de cancelación especificados. Ambas posiciones de secuencias están avanzadas por el número de bytes copiados. (Heredado de Stream) |
| CopyToAsync(Stream, Int32, CancellationToken) |
Lee de forma asincrónica los bytes de la secuencia de archivos actual y los escribe en otra secuencia, mediante un tamaño de búfer y un token de cancelación especificados. (Heredado de FileStream) |
| CopyToAsync(Stream, Int32) |
Lee de forma asincrónica los bytes de la secuencia actual y los escribe en otra secuencia mediante un tamaño de búfer especificado. Ambas posiciones de secuencias están avanzadas por el número de bytes copiados. (Heredado de Stream) |
| CopyToAsync(Stream) |
Lee asincrónicamente los bytes de la secuencia actual y los escribe en otra secuencia. Ambas posiciones de secuencias están avanzadas por el número de bytes copiados. (Heredado de Stream) |
| CreateObjRef(Type) |
Crea un objeto que contiene toda la información pertinente necesaria para generar un proxy usado para comunicarse con un objeto remoto. (Heredado de MarshalByRefObject) |
| CreateWaitHandle() |
Obsoletos.
Obsoletos.
Obsoletos.
Asigna un WaitHandle objeto . (Heredado de Stream) |
| Dispose() |
Libera todos los recursos usados por .Stream (Heredado de Stream) |
| Dispose(Boolean) |
Libera los recursos no administrados utilizados por IsolatedStorageFileStream y, opcionalmente, libera los recursos administrados. |
| DisposeAsync() |
Libera de forma asincrónica los recursos no administrados usados por .IsolatedStorageFileStream |
| EndRead(IAsyncResult) |
Finaliza una solicitud de lectura asincrónica pendiente. |
| EndWrite(IAsyncResult) |
Finaliza una escritura asincrónica. |
| Equals(Object) |
Determina si el objeto especificado es igual al objeto actual. (Heredado de Object) |
| Flush() |
Borra los búferes de esta secuencia y hace que los datos almacenados en búfer se escriban en el archivo. |
| Flush(Boolean) |
Borra los búferes de esta secuencia y hace que los datos almacenados en búfer se escriban en el archivo y también borra todos los búferes de archivos intermedios. |
| FlushAsync() |
Borra de forma asincrónica todos los búferes de esta secuencia y hace que los datos almacenados en búfer se escriban en el dispositivo subyacente. (Heredado de Stream) |
| FlushAsync(CancellationToken) |
Borra de forma asincrónica los búferes de esta secuencia y hace que los datos almacenados en búfer se escriban en el archivo. |
| FlushAsync(CancellationToken) |
Borra de forma asincrónica todos los búferes de esta secuencia, hace que los datos almacenados en búfer se escriban en el archivo y supervisa las solicitudes de cancelación. (Heredado de FileStream) |
| GetAccessControl() |
Obtiene un FileSecurity objeto que encapsula las entradas de la lista de control de acceso (ACL) para el archivo descrito por el objeto actual FileStream . (Heredado de FileStream) |
| GetHashCode() |
Actúa como función hash predeterminada. (Heredado de Object) |
| GetLifetimeService() |
Obsoletos.
Recupera el objeto de servicio de duración actual que controla la directiva de duración de esta instancia. (Heredado de MarshalByRefObject) |
| GetType() |
Obtiene el Type de la instancia actual. (Heredado de Object) |
| InitializeLifetimeService() |
Obsoletos.
Obtiene un objeto de servicio de duración para controlar la directiva de duración de esta instancia. (Heredado de MarshalByRefObject) |
| Lock(Int64, Int64) |
Impide que otros procesos lean o escriban en la secuencia. |
| Lock(Int64, Int64) |
Impide que otros procesos lean o escriban en .FileStream (Heredado de FileStream) |
| MemberwiseClone() |
Crea una copia superficial del Objectactual. (Heredado de Object) |
| MemberwiseClone(Boolean) |
Crea una copia superficial del objeto actual MarshalByRefObject . (Heredado de MarshalByRefObject) |
| ObjectInvariant() |
Obsoletos.
Proporciona compatibilidad con .Contract (Heredado de Stream) |
| Read(Byte[], Int32, Int32) |
Copia bytes del objeto almacenado en IsolatedStorageFileStream búfer actual en una matriz de bytes. |
| Read(Span<Byte>) |
Copia bytes del objeto almacenado en IsolatedStorageFileStream búfer actual en un intervalo de bytes. |
| ReadAsync(Byte[], Int32, Int32, CancellationToken) |
Copia de forma asincrónica bytes del objeto almacenado en IsolatedStorageFileStream búfer actual en una matriz de bytes. |
| ReadAsync(Byte[], Int32, Int32, CancellationToken) |
Lee de forma asincrónica una secuencia de bytes de la secuencia de archivos actual y las escribe en una matriz de bytes a partir de un desplazamiento especificado, avanza la posición dentro de la secuencia de archivos por el número de bytes leídos y supervisa las solicitudes de cancelación. (Heredado de FileStream) |
| ReadAsync(Byte[], Int32, Int32) |
Lee de forma asincrónica una secuencia de bytes de la secuencia actual y avanza la posición dentro de la secuencia por el número de bytes leídos. (Heredado de Stream) |
| ReadAsync(Memory<Byte>, CancellationToken) |
Copia de forma asincrónica bytes del objeto almacenado en IsolatedStorageFileStream búfer actual en un intervalo de memoria de bytes. |
| ReadAtLeast(Span<Byte>, Int32, Boolean) |
Lee al menos un número mínimo de bytes de la secuencia actual y avanza la posición dentro de la secuencia por el número de bytes leídos. (Heredado de Stream) |
| ReadAtLeastAsync(Memory<Byte>, Int32, Boolean, CancellationToken) |
Lee de forma asincrónica al menos un número mínimo de bytes de la secuencia actual, avanza la posición dentro de la secuencia por el número de bytes leídos y supervisa las solicitudes de cancelación. (Heredado de Stream) |
| ReadByte() |
Lee un solo byte del IsolatedStorageFileStream objeto en almacenamiento aislado. |
| ReadExactly(Byte[], Int32, Int32) |
|
| ReadExactly(Span<Byte>) |
Lee bytes de la secuencia actual y avanza la posición dentro de la secuencia hasta |
| ReadExactlyAsync(Byte[], Int32, Int32, CancellationToken) |
Lee |
| ReadExactlyAsync(Memory<Byte>, CancellationToken) |
Lee de forma asincrónica los bytes de la secuencia actual, avanza la posición dentro de la secuencia hasta |
| Seek(Int64, SeekOrigin) |
Establece la posición actual de este IsolatedStorageFileStream objeto en el valor especificado. |
| SetAccessControl(FileSecurity) |
Aplica entradas de lista de control de acceso (ACL) descritas por un FileSecurity objeto al archivo descrito por el objeto actual FileStream . (Heredado de FileStream) |
| SetLength(Int64) |
Establece la longitud de este IsolatedStorageFileStream objeto en el especificado |
| ToString() |
Devuelve una cadena que representa el objeto actual. (Heredado de Object) |
| Unlock(Int64, Int64) |
Permite que otros procesos accedan a todo o parte de un archivo que se bloqueó anteriormente. |
| Unlock(Int64, Int64) |
Permite el acceso de otros procesos a todo o parte de un archivo que se bloqueó anteriormente. (Heredado de FileStream) |
| Write(Byte[], Int32, Int32) |
Escribe un bloque de bytes en el objeto de secuencia de archivos de almacenamiento aislado mediante datos leídos de un búfer que consta de una matriz de bytes. |
| Write(ReadOnlySpan<Byte>) |
Escribe un bloque de bytes en el objeto de secuencia de archivos de almacenamiento aislado mediante datos leídos de un búfer que consta de un intervalo de bytes de solo lectura. |
| WriteAsync(Byte[], Int32, Int32, CancellationToken) |
Escribe de forma asincrónica un bloque de bytes en el objeto de secuencia de archivos de almacenamiento aislado mediante datos leídos de un búfer que consta de una matriz de bytes. |
| WriteAsync(Byte[], Int32, Int32, CancellationToken) |
Escribe de forma asincrónica una secuencia de bytes en la secuencia actual, avanza la posición actual dentro de esta secuencia por el número de bytes escritos y supervisa las solicitudes de cancelación. (Heredado de FileStream) |
| WriteAsync(Byte[], Int32, Int32) |
Escribe de forma asincrónica una secuencia de bytes en la secuencia actual y avanza la posición actual dentro de esta secuencia por el número de bytes escritos. (Heredado de Stream) |
| WriteAsync(ReadOnlyMemory<Byte>, CancellationToken) |
Escribe de forma asincrónica un bloque de bytes en el objeto de secuencia de archivos de almacenamiento aislado mediante datos leídos desde un búfer que consta de un intervalo de memoria de bytes de solo lectura. |
| WriteByte(Byte) |
Escribe un solo byte en el IsolatedStorageFileStream objeto . |
Implementaciones de interfaz explícitas
| Nombre | Description |
|---|---|
| IDisposable.Dispose() |
Libera todos los recursos usados por .Stream (Heredado de Stream) |
Métodos de extensión
| Nombre | Description |
|---|---|
| AsInputStream(Stream) |
Convierte una secuencia administrada en .NET para aplicaciones de la Tienda Windows en un flujo de entrada en Windows Runtime. |
| AsOutputStream(Stream) |
Convierte una secuencia administrada en .NET para aplicaciones de la Tienda Windows en un flujo de salida en Windows Runtime. |
| AsRandomAccessStream(Stream) |
Convierte la secuencia especificada en una secuencia de acceso aleatorio. |
| ConfigureAwait(IAsyncDisposable, Boolean) |
Configura cómo se realizarán las esperas en las tareas devueltas desde un descartable asincrónico. |
| CopyToAsync(Stream, PipeWriter, CancellationToken) |
Lee asincrónicamente los bytes de Stream y los escribe en el especificado PipeWritermediante un token de cancelación. |
| GetAccessControl(FileStream) |
Devuelve la información de seguridad de un archivo. |
| SetAccessControl(FileStream, FileSecurity) |
Cambia los atributos de seguridad de un archivo existente. |