IsolatedStorageFileStream 클래스

정의

격리된 스토리지 내 파일을 노출합니다.

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
상속
IsolatedStorageFileStream
상속
IsolatedStorageFileStream
특성

예제

다음 콘솔 애플리케이션을 사용 하는 방법을 보여 줍니다 IsolatedStorageFileIsolatedStorageFileStream 격리 된 스토리지 파일에 데이터를 쓰려고 합니다. 사용자가 로그인하도록 요청됩니다. 사용자가 새 사용자인 경우 뉴스 URL 및 스포츠 URL은 격리된 스토리지에 개인 기본 설정으로 기록됩니다. 사용자가 반환되는 사용자인 경우 사용자의 현재 기본 설정이 표시됩니다. 이 네임 스페이스 전체에서 사용 된 코드 예제는이 샘플 애플리케이션의 컨텍스트에서 표시 됩니다. 사용할 수는 Storeadm.exe (격리 된 스토리지 도구) 유틸리티를 나열 하 고이 콘솔 애플리케이션을 사용 하 여 만든 격리 된 스토리지 파일을 제거 합니다.

// 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

설명

이 클래스를 사용하여 격리된 스토리지에서 파일을 읽고, 쓰고, 만듭니다.

이 클래스는 를 확장하므로 FileStream또는 를 생성하는 StreamReader 것과 같이 가 사용될 수 있는 FileStream 대부분의 상황에서 의 instance IsolatedStorageFileStreamStreamWriter사용할 수 있습니다.

이 형식이 구현 하는 IDisposable 인터페이스입니다. 형식을 사용 하 여 마쳤으면 직접 또는 간접적으로의 삭제 해야 있습니다. 직접 형식의 dispose 호출 해당 Dispose 의 메서드를 try/catch 블록입니다. 삭제 하지 직접, 언어 구문 같은 사용 using (C#에서) 또는 Using (Visual Basic에서는). 자세한 내용은 "를 사용 하는 개체는 구현 IDisposable" 섹션을 참조 하세요.를 IDisposable 인터페이스 항목입니다.

중요

Windows 8.x 스토어 앱에는 격리된 스토리지를 사용할 수 없습니다. 대신에 Windows Runtime API에 포함된 Windows.Storage 네임스페이스의 애플리케이션 데이터 클래스를 사용하여 로컬 데이터 및 파일을 저장합니다. 자세한 내용은 Windows 개발자 센터에서 애플리케이션 데이터 를 참조하세요.

생성자

IsolatedStorageFileStream(String, FileMode)

IsolatedStorageFileStream 개체의 새 인스턴스를 초기화하여 지정된 path에서 mode에 지정된 파일에 액세스할 수 있도록 합니다.

IsolatedStorageFileStream(String, FileMode, FileAccess)

IsolatedStorageFileStream 클래스의 새 인스턴스를 초기화하여 지정된 path에서 요청한 mode 종류를 사용하여 access로 지정된 파일에 액세스할 수 있도록 합니다.

IsolatedStorageFileStream(String, FileMode, FileAccess, FileShare)

IsolatedStorageFileStream 클래스의 새 인스턴스를 초기화하여 지정된 path에서, 지정된 파일 modeaccess에 지정된 파일 공유 모드를 사용하여 share에 지정된 파일에 액세스할 수 있도록 합니다.

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

IsolatedStorageFileStream 클래스의 새 인스턴스를 초기화하여 지정된 path에서, 지정된 파일 mode, access로 지정된 파일 공유 모드, 지정된 share를 사용하여 buffersize로 지정된 파일에 액세스할 수 있도록 합니다.

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

IsolatedStorageFileStream 클래스의 새 인스턴스를 초기화하여 지정된 path에서, 지정된 파일 mode, access로 지정된 파일 공유 모드, 지정된 share, buffersize로 지정된 IsolatedStorageFile 컨텍스트를 사용하여 isf로 지정된 파일에 액세스할 수 있도록 합니다.

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

IsolatedStorageFileStream 클래스의 새 인스턴스를 초기화하여 지정된 path에서, 지정된 파일 mode, access에 지정된 파일 공유 모드, share에 지정된 IsolatedStorageFile 컨텍스트를 사용하여 isf에 지정된 파일에 액세스할 수 있도록 합니다.

IsolatedStorageFileStream(String, FileMode, FileAccess, IsolatedStorageFile)

IsolatedStorageFileStream 클래스의 새 인스턴스를 초기화하여 지정된 path에서, 지정된 파일 mode, access에 지정된 IsolatedStorageFile 컨텍스트 등을 사용하여 isf에 지정된 파일에 액세스할 수 있도록 합니다.

IsolatedStorageFileStream(String, FileMode, IsolatedStorageFile)

IsolatedStorageFileStream 클래스의 새 인스턴스를 초기화하여 지정된 path에서, mode로 지정된 IsolatedStorageFile 컨텍스트를 사용하여 isf로 지정된 파일에 액세스할 수 있도록 합니다.

속성

CanRead

파일을 읽을 수 있는지 여부를 나타내는 부울 값을 가져옵니다.

CanSeek

seek 작업이 지원되는지 여부를 나타내는 부울 값을 가져옵니다.

CanTimeout

현재 스트림이 시간 초과될 수 있는지를 결정하는 값을 가져옵니다.

(다음에서 상속됨 Stream)
CanWrite

파일에 쓸 수 있는지 여부를 나타내는 부울 값을 가져옵니다.

Handle
사용되지 않음.
사용되지 않음.
사용되지 않음.

현재 IsolatedStorageFileStream 개체가 캡슐화할 파일에 대한 파일 핸들을 가져옵니다. IsolatedStorageFileStream 개체에서는 이 속성에 액세스할 수 없으며 액세스하려고 하면 IsolatedStorageException이 throw됩니다.

IsAsync

IsolatedStorageFileStream 개체가 동기적으로 열렸는지 또는 비동기적으로 열렸는지를 나타내는 부울 값을 가져옵니다.

Length

IsolatedStorageFileStream 개체의 길이를 가져옵니다.

Name

FileStream에서 열린 파일의 절대 경로를 가져옵니다.

(다음에서 상속됨 FileStream)
Position

현재 IsolatedStorageFileStream 개체의 현재 위치를 가져오거나 설정합니다.

ReadTimeout

스트림 읽기 시도가 만료되기 전까지 기다릴 시간을 결정하는 값(밀리초)을 가져오거나 설정합니다.

(다음에서 상속됨 Stream)
SafeFileHandle

현재 IsolatedStorageFileStream 개체가 캡슐화하는 파일에 대한 운영 체제 파일 핸들을 나타내는 SafeFileHandle 개체를 가져옵니다.

SafeFileHandle

현재 FileStream 개체가 캡슐화하는 파일에 대한 운영 체제 파일 핸들을 나타내는 SafeFileHandle 개체를 가져옵니다.

(다음에서 상속됨 FileStream)
WriteTimeout

스트림 쓰기 시도가 만료되기 전까지 기다릴 시간을 결정하는 값(밀리초)을 가져오거나 설정합니다.

(다음에서 상속됨 Stream)

메서드

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

비동기 읽기를 시작합니다.

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

비동기 읽기 작업을 시작합니다. 대신 ReadAsync(Byte[], Int32, Int32)를 사용하세요.

(다음에서 상속됨 Stream)
BeginWrite(Byte[], Int32, Int32, AsyncCallback, Object)

비동기 쓰기를 시작합니다.

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

비동기 쓰기 작업을 시작합니다. 대신 WriteAsync(Byte[], Int32, Int32)를 사용하세요.

(다음에서 상속됨 Stream)
Close()

IsolatedStorageFileStream 개체와 연결된 리소스를 해제합니다.

Close()

현재 스트림을 닫고 현재 스트림과 관련된 소켓과 파일 핸들 등의 리소스를 모두 해제합니다. 이 메서드를 호출하는 대신 스트림이 올바르게 삭제되었는지 확인합니다.

(다음에서 상속됨 Stream)
Close()

현재 스트림을 닫고 현재 스트림과 관련된 소켓과 파일 핸들 등의 리소스를 모두 해제합니다.

(다음에서 상속됨 FileStream)
CopyTo(Stream)

현재 스트림에서 바이트를 읽어서 다른 스트림에 해당 바이트를 씁니다. 두 스트림 위치는 복사된 바이트 수에 따라 고급입니다.

(다음에서 상속됨 Stream)
CopyTo(Stream, Int32)

현재 스트림에서 바이트를 읽어서 지정된 버퍼 크기로 다른 스트림에 씁니다. 두 스트림 위치는 복사된 바이트 수에 따라 고급입니다.

(다음에서 상속됨 Stream)
CopyTo(Stream, Int32)

격리된 스토리지 내 파일을 노출합니다.

(다음에서 상속됨 FileStream)
CopyToAsync(Stream)

현재 스트림에서 모든 바이트를 비동기적으로 읽어 다른 스트림에 씁니다. 두 스트림 위치는 복사된 바이트 수에 따라 고급입니다.

(다음에서 상속됨 Stream)
CopyToAsync(Stream, CancellationToken)

현재 스트림에서 바이트를 비동기적으로 읽어 지정된 취소 토큰을 사용하여 다른 스트림에 씁니다. 두 스트림 위치는 복사된 바이트 수에 따라 고급입니다.

(다음에서 상속됨 Stream)
CopyToAsync(Stream, Int32)

현재 스트림에서 바이트를 비동기적으로 읽어 지정된 버퍼 크기로 다른 스트림에 씁니다. 두 스트림 위치는 복사된 바이트 수에 따라 고급입니다.

(다음에서 상속됨 Stream)
CopyToAsync(Stream, Int32, CancellationToken)

현재 스트림에서 바이트를 비동기적으로 읽어 지정된 버퍼 크기 및 취소 토큰을 사용하여 다른 스트림에 씁니다. 두 스트림 위치는 복사된 바이트 수에 따라 고급입니다.

(다음에서 상속됨 Stream)
CopyToAsync(Stream, Int32, CancellationToken)

현재 파일 스트림에서 바이트를 비동기적으로 읽어 지정된 버퍼 크기 및 취소 토큰을 사용하여 다른 스트림에 씁니다.

(다음에서 상속됨 FileStream)
CreateObjRef(Type)

원격 개체와 통신하는 데 사용되는 프록시 생성에 필요한 모든 관련 정보가 들어 있는 개체를 만듭니다.

(다음에서 상속됨 MarshalByRefObject)
CreateWaitHandle()
사용되지 않음.
사용되지 않음.
사용되지 않음.

WaitHandle 개체를 할당합니다.

(다음에서 상속됨 Stream)
Dispose()

Stream에서 사용하는 모든 리소스를 해제합니다.

(다음에서 상속됨 Stream)
Dispose(Boolean)

IsolatedStorageFileStream에서 사용하는 관리되지 않는 리소스를 해제하고, 관리되는 리소스를 선택적으로 해제할 수 있습니다.

DisposeAsync()

IsolatedStorageFileStream에서 사용하는 관리되지 않는 리소스를 비동기적으로 해제합니다.

DisposeAsync()

Stream에서 사용하는 관리되지 않는 리소스를 비동기적으로 해제합니다.

(다음에서 상속됨 Stream)
DisposeAsync()

FileStream에서 사용하는 관리되지 않는 리소스를 비동기적으로 해제합니다.

(다음에서 상속됨 FileStream)
EndRead(IAsyncResult)

보류 중인 비동기 읽기 요청을 끝냅니다.

EndRead(IAsyncResult)

보류 중인 비동기 읽기가 완료되기를 기다립니다. 대신 ReadAsync(Byte[], Int32, Int32)를 사용하세요.

(다음에서 상속됨 Stream)
EndWrite(IAsyncResult)

비동기 쓰기를 끝냅니다.

EndWrite(IAsyncResult)

비동기 쓰기 작업을 끝냅니다. 대신 WriteAsync(Byte[], Int32, Int32)를 사용하세요.

(다음에서 상속됨 Stream)
Equals(Object)

지정된 개체가 현재 개체와 같은지 확인합니다.

(다음에서 상속됨 Object)
Flush()

이 스트림의 버퍼를 지우고 버퍼링된 모든 데이터가 파일에 쓰여지도록 합니다.

Flush(Boolean)

이 스트림에 대한 버퍼를 지우고 버퍼링된 모든 데이터가 파일에 쓰여지도록 하며 모든 중간 파일 버퍼도 지웁니다.

Flush(Boolean)

이 스트림에 대한 버퍼를 지우고 버퍼링된 모든 데이터가 파일에 쓰여지도록 하며 모든 중간 파일 버퍼도 지웁니다.

(다음에서 상속됨 FileStream)
FlushAsync()

이 스트림에 대한 모든 버퍼를 비동기적으로 지우고 버퍼링된 모든 데이터가 내부 디바이스에 비동기적으로 쓰여지도록 합니다.

(다음에서 상속됨 Stream)
FlushAsync(CancellationToken)

비동기식으로 이 스트림의 버퍼를 지우고 버퍼링된 모든 데이터를 파일에 쓰도록 합니다.

FlushAsync(CancellationToken)

이 스트림에 대해 모든 버퍼를 비동기적으로 지우고 버퍼링된 데이터가 내부 디바이스에 쓰여지도록 하고 취소 요청을 모니터링합니다.

(다음에서 상속됨 FileStream)
GetAccessControl()

현재 FileSecurity 개체에서 설명하는 파일의 ACL(액세스 제어 목록) 항목을 캡슐화하는 FileStream 개체를 가져옵니다.

(다음에서 상속됨 FileStream)
GetHashCode()

기본 해시 함수로 작동합니다.

(다음에서 상속됨 Object)
GetLifetimeService()
사용되지 않음.

이 인스턴스의 수명 정책을 제어하는 현재의 수명 서비스 개체를 검색합니다.

(다음에서 상속됨 MarshalByRefObject)
GetType()

현재 인스턴스의 Type을 가져옵니다.

(다음에서 상속됨 Object)
InitializeLifetimeService()
사용되지 않음.

이 인스턴스의 수명 정책을 제어하는 수명 서비스 개체를 가져옵니다.

(다음에서 상속됨 MarshalByRefObject)
Lock(Int64, Int64)

다른 프로세스가 스트림을 읽거나 쓰지 못하게 합니다.

Lock(Int64, Int64)

다른 프로세스가 FileStream을 읽거나 쓰지 못하게 합니다.

(다음에서 상속됨 FileStream)
MemberwiseClone()

현재 Object의 단순 복사본을 만듭니다.

(다음에서 상속됨 Object)
MemberwiseClone(Boolean)

현재 MarshalByRefObject 개체의 단순 복사본을 만듭니다.

(다음에서 상속됨 MarshalByRefObject)
ObjectInvariant()
사용되지 않음.

Contract에 대한 지원을 제공합니다.

(다음에서 상속됨 Stream)
Read(Byte[], Int32, Int32)

현재 버퍼링된 IsolatedStorageFileStream 개체의 바이트를 바이트 배열에 복사합니다.

Read(Span<Byte>)

현재 버퍼링된 IsolatedStorageFileStream 개체의 바이트를 바이트 범위에 복사합니다.

Read(Span<Byte>)

파생 클래스에서 재정의되면 현재 스트림에서 바이트의 시퀀스를 읽고, 읽은 바이트 수만큼 스트림 내에서 앞으로 이동합니다.

(다음에서 상속됨 Stream)
Read(Span<Byte>)

현재 파일 스트림에서 바이트 시퀀스를 읽고 읽은 바이트 수만큼 파일 스트림에서 위치를 앞으로 이동합니다.

(다음에서 상속됨 FileStream)
ReadAsync(Byte[], Int32, Int32)

현재 스트림에서 바이트 시퀀스를 읽고 읽은 바이트 수만큼 스트림에서 위치를 비동기적으로 앞으로 이동합니다.

(다음에서 상속됨 Stream)
ReadAsync(Byte[], Int32, Int32, CancellationToken)

현재 버퍼링된 IsolatedStorageFileStream 개체의 바이트를 바이트 배열에 비동기식으로 복사합니다.

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

현재 파일 스트림에서 바이트의 시퀀스를 비동기식으로 읽고, 이를 지정된 오프셋부터 시작하여 바이트 배열에 쓰며, 읽은 바이트 수만큼 파일 스트림 내에서 앞으로 이동하며, 취소 요청을 모니터링합니다.

(다음에서 상속됨 FileStream)
ReadAsync(Memory<Byte>, CancellationToken)

현재 버퍼링된 IsolatedStorageFileStream 개체의 바이트를 바이트 메모리 범위에 비동기식으로 복사합니다.

ReadAsync(Memory<Byte>, CancellationToken)

현재 스트림에서 바이트의 시퀀스를 비동기적으로 읽고 읽은 바이트 수만큼 스트림 내에서 앞으로 이동하며 취소 요청을 모니터링합니다.

(다음에서 상속됨 Stream)
ReadAsync(Memory<Byte>, CancellationToken)

현재 파일 스트림에서 바이트의 시퀀스를 비동기식으로 읽고, 이를 메모리 범위에 쓰고, 읽은 바이트 수만큼 파일 스트림 내에서 앞으로 이동하며, 취소 요청을 모니터링합니다.

(다음에서 상속됨 FileStream)
ReadAtLeast(Span<Byte>, Int32, Boolean)

현재 스트림에서 최소 바이트 수를 읽고 읽은 바이트 수만큼 스트림 내의 위치를 진행합니다.

(다음에서 상속됨 Stream)
ReadAtLeastAsync(Memory<Byte>, Int32, Boolean, CancellationToken)

현재 스트림에서 최소 바이트 수를 비동기적으로 읽고, 스트림 내의 위치를 읽은 바이트 수만큼 발전시키고, 취소 요청을 모니터링합니다.

(다음에서 상속됨 Stream)
ReadByte()

격리된 스토리지의 IsolatedStorageFileStream 개체에서 싱글바이트를 읽습니다.

ReadExactly(Byte[], Int32, Int32)

count 현재 스트림에서 바이트 수를 읽고 스트림 내의 위치를 이동합니다.

(다음에서 상속됨 Stream)
ReadExactly(Span<Byte>)

현재 스트림에서 바이트를 읽고 가 채워질 때까지 buffer 스트림 내의 위치를 이동합니다.

(다음에서 상속됨 Stream)
ReadExactlyAsync(Byte[], Int32, Int32, CancellationToken)

현재 스트림에서 바이트 수를 비동기적으로 읽고 count , 스트림 내의 위치를 확장하고, 취소 요청을 모니터링합니다.

(다음에서 상속됨 Stream)
ReadExactlyAsync(Memory<Byte>, CancellationToken)

현재 스트림에서 바이트를 비동기적으로 읽고, 가 채워질 때까지 buffer 스트림 내의 위치를 발전시키고, 취소 요청을 모니터링합니다.

(다음에서 상속됨 Stream)
Seek(Int64, SeekOrigin)

IsolatedStorageFileStream 개체의 현재 위치를 지정된 값으로 설정합니다.

SetAccessControl(FileSecurity)

FileSecurity 개체에서 설명하는 ACL(액세스 제어 목록) 항목을 현재 FileStream 개체에서 설명하는 파일에 적용합니다.

(다음에서 상속됨 FileStream)
SetLength(Int64)

IsolatedStorageFileStream 개체의 길이를 지정된 value로 설정합니다.

ToString()

현재 개체를 나타내는 문자열을 반환합니다.

(다음에서 상속됨 Object)
Unlock(Int64, Int64)

다른 프로세스에서 이전에 잠근 파일의 일부 또는 전부에 액세스할 수 있도록 합니다.

Unlock(Int64, Int64)

다른 프로세스에서 이전에 잠근 파일의 일부 또는 전부에 액세스할 수 있도록 합니다.

(다음에서 상속됨 FileStream)
Write(Byte[], Int32, Int32)

바이트 배열로 구성된 버퍼에서 읽은 데이터를 사용하여 격리된 스토리지 파일 스트림 개체에 바이트 블록을 씁니다.

Write(ReadOnlySpan<Byte>)

읽기 전용 바이트 범위로 구성된 버퍼에서 읽은 데이터를 사용하여 격리된 스토리지 파일 스트림 개체에 바이트 블록을 씁니다.

Write(ReadOnlySpan<Byte>)

파생 클래스를 재정의될 때 현재 스트림에 바이트의 시퀀스를 쓰고 쓰여진 바이트 수만큼 이 스트림 내에서 앞으로 이동합니다.

(다음에서 상속됨 Stream)
Write(ReadOnlySpan<Byte>)

읽기 전용 범위에서 현재 파일 스트림으로 바이트 시퀀스를 쓰고 쓴 바이트 수만큼 이 파일 스트림에서 현재 위치를 앞으로 이동합니다.

(다음에서 상속됨 FileStream)
WriteAsync(Byte[], Int32, Int32)

현재 스트림에 바이트 시퀀스를 비동기적으로 쓰고 쓴 바이트 수만큼 이 스트림에서 현재 위치를 앞으로 이동합니다.

(다음에서 상속됨 Stream)
WriteAsync(Byte[], Int32, Int32, CancellationToken)

바이트 배열로 구성된 버퍼에서 읽은 데이터를 사용하여 격리된 스토리지 파일 스트림 개체에 바이트 블록을 비동기식으로 씁니다.

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

바이트의 시퀀스를 현재 스트림에 비동기적으로 쓰고 쓰여진 바이트 수만큼 이 스트림 내의 현재 위치를 앞으로 이동한 후 취소 요청을 모니터링합니다.

(다음에서 상속됨 FileStream)
WriteAsync(ReadOnlyMemory<Byte>, CancellationToken)

읽기 전용 바이트 메모리 범위로 구성된 버퍼에서 읽은 데이터를 사용하여 격리된 스토리지 파일 스트림 개체에 바이트 블록을 비동기식으로 씁니다.

WriteAsync(ReadOnlyMemory<Byte>, CancellationToken)

바이트의 시퀀스를 현재 스트림에 비동기적으로 쓰고 쓰여진 바이트 수만큼 이 스트림 내의 현재 위치를 앞으로 이동한 후 취소 요청을 모니터링합니다.

(다음에서 상속됨 Stream)
WriteAsync(ReadOnlyMemory<Byte>, CancellationToken)

메모리 영역에서 바이트의 시퀀스를 현재 버퍼링된 스트림에 비동기적으로 쓰고, 쓴 바이트 수만큼 이 파일 스트림 내의 현재 위치를 앞으로 이동한 후, 취소 요청을 모니터링합니다.

(다음에서 상속됨 FileStream)
WriteByte(Byte)

IsolatedStorageFileStream 개체에 싱글바이트를 씁니다.

명시적 인터페이스 구현

IDisposable.Dispose()

Stream에서 사용하는 모든 리소스를 해제합니다.

(다음에서 상속됨 Stream)

확장 메서드

GetAccessControl(FileStream)

파일의 보안 정보를 반환합니다.

SetAccessControl(FileStream, FileSecurity)

기존 파일의 보안 특성을 변경합니다.

AsInputStream(Stream)

Windows 스토어 앱용 .NET의 관리형 스트림을 Windows 런타임의 입력 스트림으로 변환합니다.

AsOutputStream(Stream)

Windows 스토어 앱용 .NET의 관리형 스트림을 Windows 런타임의 출력 스트림으로 변환합니다.

AsRandomAccessStream(Stream)

지정된 스트림을 임의 액세스 스트림으로 변환합니다.

ConfigureAwait(IAsyncDisposable, Boolean)

비동기 일회용에서 반환되는 작업을 대기하는 방법을 구성합니다.

적용 대상