IsolatedStorageFileStream Třída

Definice

Zpřístupňuje soubor v izolovaném úložišti.

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
Dědičnost
IsolatedStorageFileStream
Dědičnost
IsolatedStorageFileStream
Atributy

Příklady

Následující konzolová aplikace ukazuje, jak můžete použít IsolatedStorageFile a IsolatedStorageFileStream k zápisu dat do souboru izolovaného úložiště. Uživatel je požádán o přihlášení. Pokud je uživatel novým uživatelem, adresa URL příspěvků a adresa URL pro sport se zaznamenávají jako osobní předvolby v izolovaném úložišti. Pokud je uživatel vracející se uživatel, zobrazí se aktuální předvolby uživatele. Příklady kódu použité v rámci tohoto oboru názvů jsou uvedeny v kontextu této ukázkové aplikace. Pomocí nástroje Storeadm.exe (Nástroj izolovaného úložiště) můžete vypsat a odebrat soubory izolovaného úložiště, které jsou vytvořeny pomocí této konzolové aplikace.

// This sample demonstrates methods of classes found in the System.IO IsolatedStorage namespace.
using namespace System;
using namespace System::IO;
using namespace System::IO::IsolatedStorage;
using namespace System::Security::Policy;
using namespace System::Security::Permissions;

public ref class LoginPrefs
{
private:
   String^ userName;
   String^ newsUrl;
   String^ sportsUrl;
   bool newPrefs;

public:

   [SecurityPermissionAttribute(SecurityAction::Demand, Flags=SecurityPermissionFlag::UnmanagedCode)]
   bool GetPrefsForUser()
   {
      try
      {
         
         // Retrieve an IsolatedStorageFile for the current Domain and Assembly.
         IsolatedStorageFile^ isoFile = IsolatedStorageFile::GetStore( static_cast<IsolatedStorageScope>(IsolatedStorageScope::User | IsolatedStorageScope::Assembly | IsolatedStorageScope::Domain), (Type^)nullptr, nullptr );
         IsolatedStorageFileStream^ isoStream = gcnew IsolatedStorageFileStream( this->userName,FileMode::Open,FileAccess::ReadWrite,isoFile );
         
         // 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
         {
            IntPtr aFileHandle = isoStream->Handle;
            Console::WriteLine( "A pointer to a file handle has been obtained. {0} {1}", aFileHandle, aFileHandle.GetHashCode() );
         }
         catch ( Exception^ e ) 
         {
            
            // Handle the exception.
            Console::WriteLine( "Expected exception" );
            Console::WriteLine( e->ToString() );
         }

         StreamReader^ reader = gcnew StreamReader( isoStream );
         
         // Read the data.
         this->NewsUrl = reader->ReadLine();
         this->SportsUrl = reader->ReadLine();
         reader->Close();
         isoFile->Close();
         isoStream->Close();
         return false;
      }
      catch ( Exception^ e ) 
      {
         
         // Expected exception if a file cannot be found. This indicates that we have a new user.
         String^ errorMessage = e->ToString();
         return true;
      }

   }


   bool GetIsoStoreInfo()
   {
      
      // Get a User store with type evidence for the current Domain and the Assembly.
      IsolatedStorageFile^ isoFile = IsolatedStorageFile::GetStore( static_cast<IsolatedStorageScope>(IsolatedStorageScope::User | IsolatedStorageScope::Assembly | IsolatedStorageScope::Domain), System::Security::Policy::Url::typeid, System::Security::Policy::Url::typeid );
      
      array<String^>^dirNames = isoFile->GetDirectoryNames( "*" );
      array<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: {0}", 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: {0}", fileNames[ i ] );

         }
      }

      
      isoFile->Close();
      return true;
   }


   double SetPrefsForUser()
   {
      try
      {
         
         IsolatedStorageFile^ isoFile;
         isoFile = IsolatedStorageFile::GetUserStoreForDomain();
         
         // Open or create a writable file.
         IsolatedStorageFileStream^ isoStream = gcnew IsolatedStorageFileStream( this->userName,FileMode::OpenOrCreate,FileAccess::Write,isoFile );
         StreamWriter^ writer = gcnew 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 = {0}", isoFile->CurrentSize.ToString() );
         Console::WriteLine( "MaximumSize = {0}", isoFile->MaximumSize.ToString() );
         writer->Close();
         isoFile->Close();
         isoStream->Close();
         return d;
         
      }
      catch ( Exception^ e ) 
      {      
         // Add code here to handle the exception.
         Console::WriteLine( e->ToString() );
         return 0.0;
      }

   }


   void DeleteFiles()
   {
      
      try
      {
         IsolatedStorageFile^ isoFile = IsolatedStorageFile::GetStore( static_cast<IsolatedStorageScope>(IsolatedStorageScope::User | IsolatedStorageScope::Assembly | IsolatedStorageScope::Domain), System::Security::Policy::Url::typeid, System::Security::Policy::Url::typeid );
         array<String^>^dirNames = isoFile->GetDirectoryNames( "*" );
         array<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 ] );

            }
            fileNames = isoFile->GetFileNames( "*" );
         }
         isoFile->Close();
      }
      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.
   void DeleteDirectories()
   {
      try
      {
         IsolatedStorageFile^ isoFile = IsolatedStorageFile::GetStore( static_cast<IsolatedStorageScope>(IsolatedStorageScope::User | IsolatedStorageScope::Assembly | IsolatedStorageScope::Domain), System::Security::Policy::Url::typeid, System::Security::Policy::Url::typeid );
         array<String^>^dirNames = isoFile->GetDirectoryNames( "*" );
         array<String^>^fileNames = isoFile->GetFileNames( "Archive\\*" );
         
         // Delete the current files within the Archive directory.
         if ( fileNames->Length > 0 )
         {
            for ( int i = 0; i < fileNames->Length; ++i )
            {
               
               //delete files
               isoFile->DeleteFile( String::Concat("Archive\\", fileNames[ i ]) );

            }
            fileNames = isoFile->GetFileNames( "Archive\\*" );
         }
         if ( dirNames->Length > 0 )
         {
            for ( int i = 0; i < dirNames->Length; ++i )
            {
               
               // Delete the Archive directory.
               isoFile->DeleteDirectory( dirNames[ i ] );

            }
         }
         dirNames = isoFile->GetDirectoryNames( "*" );
         isoFile->Remove();
      }
      catch ( Exception^ e ) 
      {
         Console::WriteLine( e->ToString() );
      }

   }


   double SetNewPrefsForUser()
   {
      try
      {
         Byte inputChar;
         IsolatedStorageFile^ isoFile = IsolatedStorageFile::GetStore( static_cast<IsolatedStorageScope>(IsolatedStorageScope::User | IsolatedStorageScope::Assembly | IsolatedStorageScope::Domain), System::Security::Policy::Url::typeid, System::Security::Policy::Url::typeid );
         
         // If this is not a new user, archive the old preferences and 
         // overwrite them using the new preferences.
         if (  !this->NewPrefs )
         {
            if ( isoFile->GetDirectoryNames( "Archive" )->Length == 0 )
                        isoFile->CreateDirectory( "Archive" );
            else
            {
               
               // This is the stream to which data will be written.
               IsolatedStorageFileStream^ source = gcnew IsolatedStorageFileStream( this->userName,FileMode::OpenOrCreate,isoFile );
               
               // This is the stream from which data will be read.
               Console::WriteLine( "Is the source file readable?  {0}", (source->CanRead ? (String^)"true" : "false") );
               Console::WriteLine( "Creating new IsolatedStorageFileStream for Archive." );
               
               // Open or create a writable file.
               IsolatedStorageFileStream^ target = gcnew IsolatedStorageFileStream( String::Concat("Archive\\",this->userName),FileMode::OpenOrCreate,FileAccess::Write,FileShare::Write,isoFile );
               
               Console::WriteLine( "Is the target file writable? {0}", (target->CanWrite ? (String^)"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( (Byte)source->ReadByte() );
                  }
                  
                  // Determine the size of the IsolatedStorageFileStream
                  // by checking its Length property.
                  Console::WriteLine( "Total Bytes Read: {0}", source->Length.ToString() );
                  
               }
               
               // After you have read and written to the streams, close them.
               target->Close();
               source->Close();
            }
         }
         
         // Open or create a writable file, no larger than 10k
         IsolatedStorageFileStream^ isoStream = gcnew IsolatedStorageFileStream( this->userName,FileMode::OpenOrCreate,FileAccess::Write,FileShare::Write,10240,isoFile );
         
         isoStream->Position = 0; // Position to overwrite the old data.
         
         StreamWriter^ writer = gcnew 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 = {0}", isoFile->CurrentSize.ToString() );
         Console::WriteLine( "MaximumSize = {0}", isoFile->MaximumSize.ToString() );
         
         // StreamWriter.Close implicitly closes isoStream.
         writer->Close();
         isoFile->Close();
         return d;
      }
      catch ( Exception^ e ) 
      {
         Console::WriteLine( e->ToString() );
         return 0.0;
      }

   }

   LoginPrefs( String^ aUserName )
   {
      userName = aUserName;
      newPrefs = GetPrefsForUser();
   }


   property String^ NewsUrl 
   {
      String^ get()
      {
         return newsUrl;
      }

      void set( String^ value )
      {
         newsUrl = value;
      }

   }

   property String^ SportsUrl 
   {
      String^ get()
      {
         return sportsUrl;
      }

      void set( String^ value )
      {
         sportsUrl = value;
      }

   }

   property bool NewPrefs 
   {
      bool get()
      {
         return newPrefs;
      }

   }

};

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();
}

int main()
{
   
   // Prompt the user for their username.
   Console::WriteLine( "Enter your login ID:" );
   
   // Does no error checking.
   LoginPrefs^ lp = gcnew 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 {0}%", percentUsed );
   }
   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->Equals( "d" ) )
   {
      lp->DeleteFiles();
      lp->DeleteDirectories();
   }
}
// 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

Poznámky

Tato třída slouží ke čtení, zápisu a vytváření souborů v izolovaném úložišti.

Vzhledem k tomu, že tato třída rozšiřuje FileStream, můžete instanci použít IsolatedStorageFileStream ve většině situací, kdy FileStream by jinak mohl být použit, například k vytvoření StreamReader nebo StreamWriter.

Tento typ implementuje IDisposable rozhraní . Až s použitím typu skončíte, měli byste ho odstranit přímo nebo nepřímo. Chcete-li odstranit typ přímo, zavolejte jeho Dispose metodu try/catch v bloku. Pokud ho chcete odstranit nepřímo, použijte konstruktor jazyka, jako using je (v jazyce C#) nebo Using (v jazyce Visual Basic). Další informace najdete v části "Použití objektu, který implementuje IDisposable" v IDisposable tématu rozhraní.

Důležité

Izolované úložiště není k dispozici pro aplikace Windows 8.x Store. Místo toho použijte datové třídy aplikace v Windows.Storage oborech názvů zahrnutých v rozhraní API prostředí Windows Runtime k ukládání místních dat a souborů. Další informace najdete v tématu Data aplikací na webu Windows Dev Center.

Konstruktory

IsolatedStorageFileStream(String, FileMode)

Inicializuje novou instanci objektu, který IsolatedStorageFileStream poskytuje přístup k souboru určenému path v zadaném modeobjektu .

IsolatedStorageFileStream(String, FileMode, FileAccess)

Inicializuje novou instanci IsolatedStorageFileStream třídy, která poskytuje přístup k souboru určenému pathv zadaném modeobjektu , s typem požadovaného access typu.

IsolatedStorageFileStream(String, FileMode, FileAccess, FileShare)

Inicializuje novou instanci IsolatedStorageFileStream třídy, která poskytuje přístup k souboru určenému pathv zadaném modesouboru se zadaným souborem accesspomocí režimu sdílení souborů určeného nástrojem share.

IsolatedStorageFileStream(String, FileMode, FileAccess, FileShare, Int32)

Inicializuje novou instanci IsolatedStorageFileStream třídy, která poskytuje přístup k souboru určenému pathv zadaném modesouboru se zadaným souborem accesspomocí režimu sdílení souborů určeného nástrojem share, se zadaným buffersize .

IsolatedStorageFileStream(String, FileMode, FileAccess, FileShare, Int32, IsolatedStorageFile)

Inicializuje novou instanci IsolatedStorageFileStream třídy, která poskytuje přístup k souboru určenému pathv zadaném modesouboru se zadaným souborem accesspomocí režimu sdílení souborů určeného nástrojem share, se zadaným buffersize a v kontextu IsolatedStorageFile určeném nástrojem isf.

IsolatedStorageFileStream(String, FileMode, FileAccess, FileShare, IsolatedStorageFile)

Inicializuje novou instanci IsolatedStorageFileStream třídy, která poskytuje přístup k souboru určenému pathnástrojem , v zadaném modesouboru se zadaným souborem access, pomocí režimu sdílení souborů určeného nástrojem sharea v kontextu určeném IsolatedStorageFile nástrojem isf.

IsolatedStorageFileStream(String, FileMode, FileAccess, IsolatedStorageFile)

Inicializuje novou instanci IsolatedStorageFileStream třídy, která poskytuje přístup k souboru určenému path v zadaném modesouboru , se zadaným souborem accessa v kontextu určeném IsolatedStorageFile nástrojem isf.

IsolatedStorageFileStream(String, FileMode, IsolatedStorageFile)

Inicializuje novou instanci IsolatedStorageFileStream třídy, která poskytuje přístup k souboru určenému nástrojem path, v zadaném modea v kontextu zadaném IsolatedStorageFile nástrojem isf.

Vlastnosti

CanRead

Získá logickou hodnotu označující, zda lze soubor číst.

CanSeek

Získá logickou hodnotu označující, zda jsou podporovány operace hledání.

CanTimeout

Získá hodnotu, která určuje, zda aktuální datový proud může vypršení časového limitu.

(Zděděno od Stream)
CanWrite

Získá logickou hodnotu označující, zda můžete zapisovat do souboru.

Handle
Zastaralé.
Zastaralé.
Zastaralé.

Získá popisovač souboru pro soubor, který aktuální IsolatedStorageFileStream objekt zapouzdřuje. Přístup k této vlastnosti není u objektu IsolatedStorageFileStream povolen a vyvolá .IsolatedStorageException

IsAsync

Získá logickou hodnotu označující, zda IsolatedStorageFileStream byl objekt otevřen asynchronně nebo synchronně.

Length

Získá délku objektu IsolatedStorageFileStream .

Name

Získá absolutní cestu souboru otevřeného v souboru FileStream.

(Zděděno od FileStream)
Position

Získá nebo nastaví aktuální pozici aktuálního IsolatedStorageFileStream objektu.

ReadTimeout

Získá nebo nastaví hodnotu v milisekundách, která určuje, jak dlouho se datový proud pokusí číst před vypršením časového limitu.

(Zděděno od Stream)
SafeFileHandle

SafeFileHandle Získá objekt, který představuje popisovač souboru operačního systému pro soubor, který aktuální IsolatedStorageFileStream objekt zapouzdřuje.

SafeFileHandle

SafeFileHandle Získá objekt, který představuje popisovač souboru operačního systému pro soubor, který aktuální FileStream objekt zapouzdřuje.

(Zděděno od FileStream)
WriteTimeout

Získá nebo nastaví hodnotu v milisekundách, která určuje, jak dlouho se datový proud pokusí zapisovat před vypršením časového limitu.

(Zděděno od Stream)

Metody

BeginRead(Byte[], Int32, Int32, AsyncCallback, Object)

Zahájí asynchronní čtení.

BeginRead(Byte[], Int32, Int32, AsyncCallback, Object)

Spustí asynchronní operaci čtení. (Zvažte místo toho použití ReadAsync(Byte[], Int32, Int32) .)

(Zděděno od Stream)
BeginWrite(Byte[], Int32, Int32, AsyncCallback, Object)

Zahájí asynchronní zápis.

BeginWrite(Byte[], Int32, Int32, AsyncCallback, Object)

Spustí asynchronní operaci zápisu. (Zvažte místo toho použití WriteAsync(Byte[], Int32, Int32) .)

(Zděděno od Stream)
Close()

Uvolní prostředky přidružené k objektu IsolatedStorageFileStream .

Close()

Zavře aktuální datový proud a uvolní všechny prostředky (například sokety a popisovače souborů) přidružené k aktuálnímu datovému proudu. Místo volání této metody se ujistěte, že je datový proud správně odstraněn.

(Zděděno od Stream)
Close()

Zavře aktuální datový proud a uvolní všechny prostředky (například sokety a popisovače souborů) přidružené k aktuálnímu datovému proudu.

(Zděděno od FileStream)
CopyTo(Stream)

Přečte bajty z aktuálního datového proudu a zapíše je do jiného datového proudu. Obě pozice datových proudů se posouvají podle počtu zkopírovaných bajtů.

(Zděděno od Stream)
CopyTo(Stream, Int32)

Přečte bajty z aktuálního datového proudu a zapíše je do jiného datového proudu pomocí zadané velikosti vyrovnávací paměti. Obě pozice datových proudů se posouvají podle počtu zkopírovaných bajtů.

(Zděděno od Stream)
CopyTo(Stream, Int32)

Zpřístupňuje soubor v izolovaném úložišti.

(Zděděno od FileStream)
CopyToAsync(Stream)

Asynchronně přečte bajty z aktuálního datového proudu a zapíše je do jiného datového proudu. Obě pozice datových proudů se posouvají podle počtu zkopírovaných bajtů.

(Zděděno od Stream)
CopyToAsync(Stream, CancellationToken)

Asynchronně přečte bajty z aktuálního datového proudu a zapíše je do jiného datového proudu pomocí zadaného tokenu zrušení. Obě pozice datových proudů se posouvají podle počtu zkopírovaných bajtů.

(Zděděno od Stream)
CopyToAsync(Stream, Int32)

Asynchronně přečte bajty z aktuálního datového proudu a zapíše je do jiného datového proudu pomocí zadané velikosti vyrovnávací paměti. Obě pozice datových proudů se posouvají podle počtu zkopírovaných bajtů.

(Zděděno od Stream)
CopyToAsync(Stream, Int32, CancellationToken)

Asynchronně přečte bajty z aktuálního datového proudu a zapíše je do jiného datového proudu pomocí zadané velikosti vyrovnávací paměti a tokenu zrušení. Obě pozice datových proudů se posouvají podle počtu zkopírovaných bajtů.

(Zděděno od Stream)
CopyToAsync(Stream, Int32, CancellationToken)

Asynchronně přečte bajty z aktuálního datového proudu souboru a zapíše je do jiného datového proudu pomocí zadané velikosti vyrovnávací paměti a tokenu zrušení.

(Zděděno od FileStream)
CreateObjRef(Type)

Vytvoří objekt, který obsahuje všechny relevantní informace potřebné k vygenerování proxy sloužící ke komunikaci se vzdáleným objektem.

(Zděděno od MarshalByRefObject)
CreateWaitHandle()
Zastaralé.
Zastaralé.
Zastaralé.

Přidělí WaitHandle objekt.

(Zděděno od Stream)
Dispose()

Uvolní všechny prostředky používané nástrojem Stream.

(Zděděno od Stream)
Dispose(Boolean)

Uvolní nespravované prostředky používané IsolatedStorageFileStream nástrojem a volitelně uvolní spravované prostředky.

DisposeAsync()

Asynchronně uvolní nespravované prostředky používané IsolatedStorageFileStreamnástrojem .

DisposeAsync()

Asynchronně uvolní nespravované prostředky používané Streamnástrojem .

(Zděděno od Stream)
DisposeAsync()

Asynchronně uvolní nespravované prostředky používané FileStreamnástrojem .

(Zděděno od FileStream)
EndRead(IAsyncResult)

Ukončí čekající asynchronní žádost o čtení.

EndRead(IAsyncResult)

Čeká na dokončení čekajícího asynchronního čtení. (Zvažte místo toho použití ReadAsync(Byte[], Int32, Int32) .)

(Zděděno od Stream)
EndWrite(IAsyncResult)

Ukončí asynchronní zápis.

EndWrite(IAsyncResult)

Ukončí operaci asynchronního zápisu. (Zvažte místo toho použití WriteAsync(Byte[], Int32, Int32) .)

(Zděděno od Stream)
Equals(Object)

Určí, zda se zadaný objekt rovná aktuálnímu objektu.

(Zděděno od Object)
Flush()

Vymaže vyrovnávací paměti pro tento datový proud a způsobí zápis všech dat do vyrovnávací paměti do souboru.

Flush(Boolean)

Vymaže vyrovnávací paměti pro tento datový proud a způsobí zápis všech dat do vyrovnávací paměti do souboru a také vymaže všechny přechodné vyrovnávací paměti souborů.

Flush(Boolean)

Vymaže vyrovnávací paměti pro tento datový proud a způsobí zápis všech dat do vyrovnávací paměti do souboru a také vymaže všechny přechodné vyrovnávací paměti souborů.

(Zděděno od FileStream)
FlushAsync()

Asynchronně vymaže všechny vyrovnávací paměti pro tento datový proud a způsobí zápis všech dat do vyrovnávací paměti do základního zařízení.

(Zděděno od Stream)
FlushAsync(CancellationToken)

Asynchronně vymaže vyrovnávací paměti pro tento datový proud a způsobí zápis všech dat do vyrovnávací paměti do souboru.

FlushAsync(CancellationToken)

Asynchronně vymaže všechny vyrovnávací paměti pro tento datový proud, způsobí zápis všech dat do vyrovnávací paměti do základního zařízení a monitoruje žádosti o zrušení.

(Zděděno od FileStream)
GetAccessControl()

FileSecurity Získá objekt, který zapouzdřuje položky seznamu řízení přístupu (ACL) pro soubor popsaný aktuálním FileStream objektem.

(Zděděno od FileStream)
GetHashCode()

Slouží jako výchozí hashovací funkce.

(Zděděno od Object)
GetLifetimeService()
Zastaralé.

Načte aktuální životnost objektu služby, který řídí zásady životnosti pro tuto instanci.

(Zděděno od MarshalByRefObject)
GetType()

Type Získá z aktuální instance.

(Zděděno od Object)
InitializeLifetimeService()
Zastaralé.

Získá životnost objektu služby, který řídí zásady životnosti pro tuto instanci.

(Zděděno od MarshalByRefObject)
Lock(Int64, Int64)

Zabraňuje jiným procesům ve čtení nebo zápisu do datového proudu.

Lock(Int64, Int64)

Zabraňuje jiným procesům ve čtení nebo zápisu FileStreamdo .

(Zděděno od FileStream)
MemberwiseClone()

Vytvoří mělkou kopii aktuálního Objectsouboru .

(Zděděno od Object)
MemberwiseClone(Boolean)

Vytvoří mělkou kopii aktuálního MarshalByRefObject objektu.

(Zděděno od MarshalByRefObject)
ObjectInvariant()
Zastaralé.

Poskytuje podporu pro Contract.

(Zděděno od Stream)
Read(Byte[], Int32, Int32)

Zkopíruje bajty z aktuálního objektu ve IsolatedStorageFileStream vyrovnávací paměti do pole bajtů.

Read(Span<Byte>)

Zkopíruje bajty z aktuálního objektu ve IsolatedStorageFileStream vyrovnávací paměti do rozsahu bajtů.

Read(Span<Byte>)

Při přepsání v odvozené třídě přečte sekvenci bajtů z aktuálního datového proudu a posune pozici v rámci datového proudu o počet přečtených bajtů.

(Zděděno od Stream)
Read(Span<Byte>)

Načte posloupnost bajtů z aktuálního datového proudu souboru a posune pozici v datovém proudu souboru o počet přečtených bajtů.

(Zděděno od FileStream)
ReadAsync(Byte[], Int32, Int32)

Asynchronně přečte posloupnost bajtů z aktuálního datového proudu a posune pozici v rámci datového proudu o počet přečtených bajtů.

(Zděděno od Stream)
ReadAsync(Byte[], Int32, Int32, CancellationToken)

Asynchronně kopíruje bajty z aktuálního objektu ve IsolatedStorageFileStream vyrovnávací paměti do pole bajtů.

ReadAsync(Byte[], Int32, Int32, CancellationToken)

Asynchronně přečte posloupnost bajtů z aktuálního datového proudu souboru a zapíše je do pole bajtů začínajícího na zadaném posunu, posune pozici v datovém proudu souboru o počet přečtených bajtů a monitoruje požadavky na zrušení.

(Zděděno od FileStream)
ReadAsync(Memory<Byte>, CancellationToken)

Asynchronně kopíruje bajty z aktuálního objektu ve IsolatedStorageFileStream vyrovnávací paměti do rozsahu paměti bajtů.

ReadAsync(Memory<Byte>, CancellationToken)

Asynchronně přečte sekvenci bajtů z aktuálního datového proudu, posune pozici v rámci datového proudu o počet přečtených bajtů a sleduje požadavky na zrušení.

(Zděděno od Stream)
ReadAsync(Memory<Byte>, CancellationToken)

Asynchronně přečte posloupnost bajtů z aktuálního datového proudu souboru a zapíše je do oblasti paměti, posune pozici v datovém proudu souboru o počet přečtených bajtů a monitoruje požadavky na zrušení.

(Zděděno od FileStream)
ReadAtLeast(Span<Byte>, Int32, Boolean)

Přečte alespoň minimální počet bajtů z aktuálního datového proudu a posune pozici v rámci datového proudu o počet přečtených bajtů.

(Zděděno od Stream)
ReadAtLeastAsync(Memory<Byte>, Int32, Boolean, CancellationToken)

Asynchronně přečte alespoň minimální počet bajtů z aktuálního datového proudu, posune pozici v rámci datového proudu o počet přečtených bajtů a sleduje požadavky na zrušení.

(Zděděno od Stream)
ReadByte()

Načte jeden bajt z objektu v izolovaném IsolatedStorageFileStream úložišti.

ReadExactly(Byte[], Int32, Int32)

Načte count počet bajtů z aktuálního datového proudu a posune pozici v rámci datového proudu.

(Zděděno od Stream)
ReadExactly(Span<Byte>)

Načte bajty z aktuálního datového proudu a posune pozici v rámci datového proudu, dokud buffer není vyplněna.

(Zděděno od Stream)
ReadExactlyAsync(Byte[], Int32, Int32, CancellationToken)

Asynchronně načte count počet bajtů z aktuálního datového proudu, posune pozici v rámci datového proudu a monitoruje požadavky na zrušení.

(Zděděno od Stream)
ReadExactlyAsync(Memory<Byte>, CancellationToken)

Asynchronně čte bajty z aktuálního datového proudu, posune pozici v rámci datového proudu až do buffer vyplnění a monitoruje žádosti o zrušení.

(Zděděno od Stream)
Seek(Int64, SeekOrigin)

Nastaví aktuální pozici tohoto IsolatedStorageFileStream objektu na zadanou hodnotu.

SetAccessControl(FileSecurity)

Použije položky seznamu řízení přístupu (ACL) popsané objektem FileSecurity na soubor popsaný aktuálním FileStream objektem.

(Zděděno od FileStream)
SetLength(Int64)

Nastaví délku tohoto IsolatedStorageFileStream objektu na zadanou valuehodnotu .

ToString()

Vrátí řetězec, který představuje aktuální objekt.

(Zděděno od Object)
Unlock(Int64, Int64)

Umožňuje jiným procesům přístup k celému souboru nebo jeho části, který byl dříve uzamčen.

Unlock(Int64, Int64)

Umožňuje jiným procesům přístup k celému souboru nebo jeho části, který byl dříve uzamčen.

(Zděděno od FileStream)
Write(Byte[], Int32, Int32)

Zapíše blok bajtů do objektu streamu souboru izolovaného úložiště pomocí dat načtených z vyrovnávací paměti skládající se z pole bajtů.

Write(ReadOnlySpan<Byte>)

Zapíše blok bajtů do objektu streamu souboru izolovaného úložiště pomocí dat načtených z vyrovnávací paměti sestávající z bajtového rozsahu jen pro čtení.

Write(ReadOnlySpan<Byte>)

Při přepsání v odvozené třídě zapíše sekvenci bajtů do aktuálního datového proudu a posune aktuální pozici v rámci tohoto datového proudu o počet zapsaných bajtů.

(Zděděno od Stream)
Write(ReadOnlySpan<Byte>)

Zapíše posloupnost bajtů z rozsahu jen pro čtení do aktuálního datového proudu souboru a posune aktuální pozici v tomto datovém proudu souboru o počet zapsaných bajtů.

(Zděděno od FileStream)
WriteAsync(Byte[], Int32, Int32)

Asynchronně zapíše posloupnost bajtů do aktuálního datového proudu a posune aktuální pozici v rámci tohoto datového proudu o počet zapsaných bajtů.

(Zděděno od Stream)
WriteAsync(Byte[], Int32, Int32, CancellationToken)

Asynchronně zapíše blok bajtů do objektu streamu izolovaného souboru úložiště pomocí dat načtených z vyrovnávací paměti skládající se z pole bajtů.

WriteAsync(Byte[], Int32, Int32, CancellationToken)

Asynchronně zapíše posloupnost bajtů do aktuálního datového proudu, posune aktuální pozici v rámci tohoto streamu o počet zapsaných bajtů a monitoruje žádosti o zrušení.

(Zděděno od FileStream)
WriteAsync(ReadOnlyMemory<Byte>, CancellationToken)

Asynchronně zapíše blok bajtů do objektu streamu izolovaného souboru úložiště pomocí dat načtených z vyrovnávací paměti sestávající z rozsahu bajtů jen pro čtení.

WriteAsync(ReadOnlyMemory<Byte>, CancellationToken)

Asynchronně zapíše sekvenci bajtů do aktuálního datového proudu, posune aktuální pozici v rámci tohoto datového proudu o počet zapsaných bajtů a sleduje požadavky na zrušení.

(Zděděno od Stream)
WriteAsync(ReadOnlyMemory<Byte>, CancellationToken)

Asynchronně zapíše posloupnost bajtů z oblasti paměti do aktuálního datového proudu souboru, posune aktuální pozici v rámci tohoto datového proudu souboru o počet zapsaných bajtů a monitoruje požadavky na zrušení.

(Zděděno od FileStream)
WriteByte(Byte)

Zapíše do objektu IsolatedStorageFileStream jeden bajt.

Explicitní implementace rozhraní

IDisposable.Dispose()

Uvolní všechny prostředky používané nástrojem Stream.

(Zděděno od Stream)

Metody rozšíření

GetAccessControl(FileStream)

Vrátí informace o zabezpečení souboru.

SetAccessControl(FileStream, FileSecurity)

Změní atributy zabezpečení existujícího souboru.

AsInputStream(Stream)

Převede spravovaný datový proud v aplikacích .NET pro Windows Store na vstupní datový proud v prostředí Windows Runtime.

AsOutputStream(Stream)

Převede spravovaný datový proud v aplikacích .NET pro Windows Store na výstupní datový proud v prostředí Windows Runtime.

AsRandomAccessStream(Stream)

Převede zadaný datový proud na datový proud s náhodným přístupem.

ConfigureAwait(IAsyncDisposable, Boolean)

Konfiguruje, jak se provádí funkce awaits u úloh vrácených z asynchronního jednorázového režimu.

Platí pro