IsolatedStorageFileStreamとは? わかりやすく解説

IsolatedStorageFileStream クラス

分離ストレージ内のファイルを公開します。

名前空間: System.IO.IsolatedStorage
アセンブリ: mscorlib (mscorlib.dll 内)
構文構文

<ComVisibleAttribute(True)> _
Public Class IsolatedStorageFileStream
    Inherits FileStream
Dim instance As IsolatedStorageFileStream
[ComVisibleAttribute(true)] 
public class IsolatedStorageFileStream : FileStream
[ComVisibleAttribute(true)] 
public ref class IsolatedStorageFileStream
 : public FileStream
/** @attribute ComVisibleAttribute(true) */ 
public class IsolatedStorageFileStream extends
 FileStream
ComVisibleAttribute(true) 
public class IsolatedStorageFileStream extends
 FileStream
解説解説

このクラスを使用して、分離ストレージのファイルの読み取り、書き込み、および作成を行います。

このクラスは FileStream を拡張したクラスであるため、StreamReader または StreamWriter の構築など、通常なら FileStream を使用する多くの場面で IsolatedStorageFileStream のインスタンスを使用できます。

使用例使用例

次のコンソール アプリケーションでは、IsolatedStorageFile と IsolatedStorageFileStream を使用して、分離ストレージ ファイルにデータを書き込む例を示しています。このアプリケーションでは、ユーザーはログインを要求されます。ユーザーが新規ユーザーの場合は、News 用 URL および Sports 用 URL が分離ストレージファイルに個人用の環境設定として記録されます。ユーザーが以前にもログインしたことのある場合は、そのユーザーの現在の環境設定が表示されます。この名前空間全体を通じて使用するコード例は、このサンプル アプリケーションを前提としています。分離ストレージ ツール (Storeadm.exe) ユーティリティを使用すると、このコンソール アプリケーションで作成された分離ストレージファイルを一覧および削除できます。

'This sample demonstrates methods of classes found in the System.IO
 IsolatedStorage namespace.
Imports System
Imports System.IO
Imports System.IO.IsolatedStorage
Imports System.Security.Policy
Imports Microsoft.VisualBasic
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 'Main


        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 'GatherInfoFromUser
    End Class 'ConsoleApp
    _

    <SecurityPermissionAttribute(SecurityAction.Demand, Flags:=SecurityPermissionFlag.UnmanagedCode)>
 _
    Public Class LoginPrefs

        Public Sub New(ByVal
 myUserName As String)
            userName = myUserName
            myNewPrefs = GetPrefsForUser()
        End Sub 'New
        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(Me.userName, FileMode.Open, _
                    FileAccess.Read, 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 'DeleteFiles

        ' 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 'DeleteDirectories

        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 'LoginPrefs
End Namespace 'ISOCS
// 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;
using System.Security.Permissions;

[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();
    }
}
[SecurityPermissionAttribute(SecurityAction.Demand, Flags=SecurityPermissionFlag.UnmanagedCode)]
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(this.userName
,
                FileMode.Open,
                FileAccess.Read,
                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.
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();
   }
}

継承階層継承階層
System.Object
   System.MarshalByRefObject
     System.IO.Stream
       System.IO.FileStream
        System.IO.IsolatedStorage.IsolatedStorageFileStream
スレッド セーフスレッド セーフ
この型の public static (Visual Basic では Shared) メンバはすべて、スレッド セーフです。インスタンス メンバの場合は、スレッド セーフであるとは限りません。
プラットフォームプラットフォーム
バージョン情報バージョン情報
参照参照
関連項目
IsolatedStorageFileStream メンバ
System.IO.IsolatedStorage 名前空間

IsolatedStorageFileStream コンストラクタ (String, FileMode)

指定した mode で、path によって指定されたファイルへのアクセスを与える IsolatedStorageFileStream オブジェクトの新しいインスタンスを初期化します。

名前空間: System.IO.IsolatedStorage
アセンブリ: mscorlib (mscorlib.dll 内)
構文構文

Public Sub New ( _
    path As String, _
    mode As FileMode _
)
Dim path As String
Dim mode As FileMode

Dim instance As New IsolatedStorageFileStream(path,
 mode)
public IsolatedStorageFileStream (
    string path,
    FileMode mode
)
public:
IsolatedStorageFileStream (
    String^ path, 
    FileMode mode
)
public IsolatedStorageFileStream (
    String path, 
    FileMode mode
)
public function IsolatedStorageFileStream (
    path : String, 
    mode : FileMode
)

パラメータ

path

分離ストレージ内でのファイルの相対パス。

mode

FileMode 値の 1 つ。

例外例外
例外の種類条件

ArgumentException

path の形式が正しくありません。

ArgumentNullException

path が null 参照 (Visual Basic では Nothing) です。

DirectoryNotFoundException

path 内にディレクトリが存在しません。

FileNotFoundException

mode に Open が設定されていますが、ファイルが見つかりません。

解説解説

使用する分離ストアのスコープは、現在実行されているアセンブリの ID と、このアセンブリを実行しているアプリケーション ドメインの ID によって指定されます。このストアは、IsolatedStorageFileStream オブジェクトの有効期間の間だけ開かれたままになります。別の分離ストレージ スコープを指定するか、ストアを開いたままにすることで、複数の IsolatedStorageFileStream オブジェクトを開くことができるようにする場合は、IsolatedStorageFile オブジェクトを扱える形式のコンストラクタを使用します。

mode パラメータは、新しいファイルを作成するか、既存のファイルを使用するかなどを示します。

注意に関するメモ注意

特定のカルチャ設定で文字セットをコンパイルし、同じ文字を異なるカルチャ設定で取得すると、文字が解釈されないことがあります。さらに、例外がスローされることもあります。

.NET Framework のセキュリティ.NET Framework のセキュリティ
プラットフォームプラットフォーム
バージョン情報バージョン情報
参照参照
関連項目
IsolatedStorageFileStream クラス
IsolatedStorageFileStream メンバ
System.IO.IsolatedStorage 名前空間

IsolatedStorageFileStream コンストラクタ (String, FileMode, IsolatedStorageFile)

mode で指定したモード、isf で指定した IsolatedStorageFile のコンテキストを使用して、path で指定したファイルへのアクセスを提供する IsolatedStorageFileStream クラスの新しいインスタンスを初期化します。

名前空間: System.IO.IsolatedStorage
アセンブリ: mscorlib (mscorlib.dll 内)
構文構文

Public Sub New ( _
    path As String, _
    mode As FileMode, _
    isf As IsolatedStorageFile _
)
Dim path As String
Dim mode As FileMode
Dim isf As IsolatedStorageFile

Dim instance As New IsolatedStorageFileStream(path,
 mode, isf)
public IsolatedStorageFileStream (
    string path,
    FileMode mode,
    IsolatedStorageFile isf
)
public:
IsolatedStorageFileStream (
    String^ path, 
    FileMode mode, 
    IsolatedStorageFile^ isf
)
public IsolatedStorageFileStream (
    String path, 
    FileMode mode, 
    IsolatedStorageFile isf
)
public function IsolatedStorageFileStream (
    path : String, 
    mode : FileMode, 
    isf : IsolatedStorageFile
)

パラメータ

path

分離ストレージ内でのファイルの相対パス。

mode

FileMode 値の 1 つ。

isf

IsolatedStorageFileStream を開くために使用する IsolatedStorageFile。

例外例外
例外の種類条件

ArgumentException

path の形式が正しくありません。

ArgumentNullException

path が null 参照 (Visual Basic では Nothing) です。

FileNotFoundException

mode に Open が設定されていますが、ファイルが見つかりません。

IsolatedStorageException

isf はクォータを持っていません。

解説解説
使用例使用例

このコンストラクタの使用方法については、次のコード例を参照してください。この例のコンテキスト全体については、IsolatedStorageFileStream の概要を参照してください。

' Open or create a writable file.
Dim target As New IsolatedStorageFileStream("Archive\
 " & Me.userName, _
     FileMode.OpenOrCreate, FileAccess.Write, FileShare.Write, isoFile)
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);
// 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
 );

.NET Framework のセキュリティ.NET Framework のセキュリティ
プラットフォームプラットフォーム
バージョン情報バージョン情報
参照参照
関連項目
IsolatedStorageFileStream クラス
IsolatedStorageFileStream メンバ
System.IO.IsolatedStorage 名前空間

IsolatedStorageFileStream コンストラクタ (String, FileMode, FileAccess, FileShare, IsolatedStorageFile)

mode で指定したモード、share で指定したファイル共有モード、isf で指定した IsolatedStorageFile のコンテキストを使用して、path で指定したファイルへの、access で指定した種類のアクセスを提供する IsolatedStorageFileStream クラスの新しいインスタンスを初期化します。

名前空間: System.IO.IsolatedStorage
アセンブリ: mscorlib (mscorlib.dll 内)
構文構文

Public Sub New ( _
    path As String, _
    mode As FileMode, _
    access As FileAccess, _
    share As FileShare, _
    isf As IsolatedStorageFile _
)
Dim path As String
Dim mode As FileMode
Dim access As FileAccess
Dim share As FileShare
Dim isf As IsolatedStorageFile

Dim instance As New IsolatedStorageFileStream(path,
 mode, access, share, isf)
public IsolatedStorageFileStream (
    string path,
    FileMode mode,
    FileAccess access,
    FileShare share,
    IsolatedStorageFile isf
)
public:
IsolatedStorageFileStream (
    String^ path, 
    FileMode mode, 
    FileAccess access, 
    FileShare share, 
    IsolatedStorageFile^ isf
)
public IsolatedStorageFileStream (
    String path, 
    FileMode mode, 
    FileAccess access, 
    FileShare share, 
    IsolatedStorageFile isf
)
public function IsolatedStorageFileStream (
    path : String, 
    mode : FileMode, 
    access : FileAccess, 
    share : FileShare, 
    isf : IsolatedStorageFile
)

パラメータ

path

分離ストレージ内でのファイルの相対パス。

mode

FileMode 値の 1 つ。

access

FileAccess 値のビットごとの組み合わせ。

share

FileShare 値のビットごとの組み合わせ。

isf

IsolatedStorageFileStream を開くために使用する IsolatedStorageFile。

例外例外
例外の種類条件

ArgumentException

path の形式が正しくありません。

ArgumentNullException

path が null 参照 (Visual Basic では Nothing) です。

FileNotFoundException

mode に Open が設定されていますが、ファイルが見つかりません。

IsolatedStorageException

isf はクォータを持っていません。

解説解説
使用例使用例

このコンストラクタの使用方法については、次のコード例を参照してください。この例のコンテキスト全体については、IsolatedStorageFileStream の概要を参照してください。

' Open or create a writable file.
Dim target As New IsolatedStorageFileStream("Archive\
 " & Me.userName, _
     FileMode.OpenOrCreate, FileAccess.Write, FileShare.Write, isoFile)
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);
// 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
 );

.NET Framework のセキュリティ.NET Framework のセキュリティ
プラットフォームプラットフォーム
バージョン情報バージョン情報
参照参照
関連項目
IsolatedStorageFileStream クラス
IsolatedStorageFileStream メンバ
System.IO.IsolatedStorage 名前空間

IsolatedStorageFileStream コンストラクタ (String, FileMode, FileAccess, FileShare)

mode で指定したモード、share で指定した共有モードを使用して、path で指定したファイルへの、access で指定した種類のアクセスを提供する IsolatedStorageFileStream クラスの新しいインスタンスを初期化します。

名前空間: System.IO.IsolatedStorage
アセンブリ: mscorlib (mscorlib.dll 内)
構文構文

Public Sub New ( _
    path As String, _
    mode As FileMode, _
    access As FileAccess, _
    share As FileShare _
)
Dim path As String
Dim mode As FileMode
Dim access As FileAccess
Dim share As FileShare

Dim instance As New IsolatedStorageFileStream(path,
 mode, access, share)
public IsolatedStorageFileStream (
    string path,
    FileMode mode,
    FileAccess access,
    FileShare share
)
public:
IsolatedStorageFileStream (
    String^ path, 
    FileMode mode, 
    FileAccess access, 
    FileShare share
)
public IsolatedStorageFileStream (
    String path, 
    FileMode mode, 
    FileAccess access, 
    FileShare share
)
public function IsolatedStorageFileStream (
    path : String, 
    mode : FileMode, 
    access : FileAccess, 
    share : FileShare
)

パラメータ

path

分離ストレージ内でのファイルの相対パス。

mode

FileMode 値の 1 つ。

access

FileAccess 値のビットごとの組み合わせ。

share

FileShare 値のビットごとの組み合わせ。

例外例外
例外の種類条件

ArgumentException

path の形式が正しくありません。

ArgumentNullException

path が null 参照 (Visual Basic では Nothing) です。

FileNotFoundException

mode に Open が設定されていますが、ファイルが見つかりません。

解説解説

使用する分離ストアのスコープは、現在実行されているアセンブリの ID と、このアセンブリを実行しているアプリケーション ドメインの ID によって指定されます。このストアは、IsolatedStorageFileStream オブジェクトの有効期間の間だけ開かれたままになります。別の分離ストレージ スコープを指定するか、ストアを開いたままにすることで、複数の IsolatedStorageFileStream オブジェクトを開くことができるようにする場合は、IsolatedStorageFile オブジェクトを扱える形式のコンストラクタを使用します。

注意に関するメモ注意

特定のカルチャ設定で文字セットをコンパイルし、同じ文字を異なるカルチャ設定で取得すると、文字が解釈されないことがあります。さらに、例外がスローされることもあります。

使用例使用例

このコンストラクタの使用方法については、次のコード例を参照してください。この例のコンテキスト全体については、IsolatedStorageFileStream の概要を参照してください。

' 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(Me.userName,
 FileMode.Open, _
    FileAccess.Read, FileShare.Read)
// 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(this.userName
,
    FileMode.Open,
    FileAccess.Read,
    FileShare.Read);
// 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
 );

.NET Framework のセキュリティ.NET Framework のセキュリティ
プラットフォームプラットフォーム
バージョン情報バージョン情報
参照参照
関連項目
IsolatedStorageFileStream クラス
IsolatedStorageFileStream メンバ
System.IO.IsolatedStorage 名前空間

IsolatedStorageFileStream コンストラクタ (String, FileMode, FileAccess, FileShare, Int32, IsolatedStorageFile)

mode で指定したモード、share で指定したファイル共有モード、buffersize で指定したバッファ サイズ、isf で指定した IsolatedStorageFile のコンテキストを使用して、path で指定したファイルへの、access で指定した種類のアクセスを提供する IsolatedStorageFileStream クラスの新しいインスタンスを初期化します。

名前空間: System.IO.IsolatedStorage
アセンブリ: mscorlib (mscorlib.dll 内)
構文構文

Public Sub New ( _
    path As String, _
    mode As FileMode, _
    access As FileAccess, _
    share As FileShare, _
    bufferSize As Integer, _
    isf As IsolatedStorageFile _
)
Dim path As String
Dim mode As FileMode
Dim access As FileAccess
Dim share As FileShare
Dim bufferSize As Integer
Dim isf As IsolatedStorageFile

Dim instance As New IsolatedStorageFileStream(path,
 mode, access, share, bufferSize, isf)
public IsolatedStorageFileStream (
    string path,
    FileMode mode,
    FileAccess access,
    FileShare share,
    int bufferSize,
    IsolatedStorageFile isf
)
public:
IsolatedStorageFileStream (
    String^ path, 
    FileMode mode, 
    FileAccess access, 
    FileShare share, 
    int bufferSize, 
    IsolatedStorageFile^ isf
)
public IsolatedStorageFileStream (
    String path, 
    FileMode mode, 
    FileAccess access, 
    FileShare share, 
    int bufferSize, 
    IsolatedStorageFile isf
)
public function IsolatedStorageFileStream (
    path : String, 
    mode : FileMode, 
    access : FileAccess, 
    share : FileShare, 
    bufferSize : int, 
    isf : IsolatedStorageFile
)

パラメータ

path

分離ストレージ内でのファイルの相対パス。

mode

FileMode 値の 1 つ。

access

FileAccess 値のビットごとの組み合わせ。

share

FileShare 値のビットごとの組み合わせ。

bufferSize

FileStream のバッファ サイズ。

isf

IsolatedStorageFileStream を開くために使用する IsolatedStorageFile。

例外例外
例外の種類条件

ArgumentException

path の形式が正しくありません。

ArgumentNullException

path が null 参照 (Visual Basic では Nothing) です。

FileNotFoundException

mode に Open が設定されていますが、ファイルが見つかりません。

IsolatedStorageException

isf はクォータを持っていません。

解説解説
使用例使用例

このコンストラクタの使用方法については、次のコード例を参照してください。この例のコンテキスト全体については、IsolatedStorageFileStream の概要を参照してください。

' 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)
// 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);
// Open or create a writable file, no larger than 10k
IsolatedStorageFileStream^ isoStream = gcnew IsolatedStorageFileStream( this->userName,FileMode::OpenOrCreate,FileAccess::Write,FileShare::Write,10240,isoFile
 );

.NET Framework のセキュリティ.NET Framework のセキュリティ
プラットフォームプラットフォーム
バージョン情報バージョン情報
参照参照
関連項目
IsolatedStorageFileStream クラス
IsolatedStorageFileStream メンバ
System.IO.IsolatedStorage 名前空間

IsolatedStorageFileStream コンストラクタ (String, FileMode, FileAccess, FileShare, Int32)

mode で指定したモード、share で指定したファイル共有モード、buffersize で指定したバッファ サイズを使用して、path で指定したファイルへの、access で指定した種類のアクセスを提供する IsolatedStorageFileStream クラスの新しいインスタンスを初期化します。

名前空間: System.IO.IsolatedStorage
アセンブリ: mscorlib (mscorlib.dll 内)
構文構文

Public Sub New ( _
    path As String, _
    mode As FileMode, _
    access As FileAccess, _
    share As FileShare, _
    bufferSize As Integer _
)
Dim path As String
Dim mode As FileMode
Dim access As FileAccess
Dim share As FileShare
Dim bufferSize As Integer

Dim instance As New IsolatedStorageFileStream(path,
 mode, access, share, bufferSize)
public IsolatedStorageFileStream (
    string path,
    FileMode mode,
    FileAccess access,
    FileShare share,
    int bufferSize
)
public:
IsolatedStorageFileStream (
    String^ path, 
    FileMode mode, 
    FileAccess access, 
    FileShare share, 
    int bufferSize
)
public IsolatedStorageFileStream (
    String path, 
    FileMode mode, 
    FileAccess access, 
    FileShare share, 
    int bufferSize
)
public function IsolatedStorageFileStream (
    path : String, 
    mode : FileMode, 
    access : FileAccess, 
    share : FileShare, 
    bufferSize : int
)

パラメータ

path

分離ストレージ内でのファイルの相対パス。

mode

FileMode 値の 1 つ。

access

FileAccess 値のビットごとの組み合わせ。

share

FileShare 値のビットごとの組み合わせ。

bufferSize

FileStream のバッファ サイズ。

例外例外
例外の種類条件

ArgumentException

path の形式が正しくありません。

ArgumentNullException

path が null 参照 (Visual Basic では Nothing) です。

FileNotFoundException

mode に Open が設定されていますが、ファイルが見つかりません。

解説解説
.NET Framework のセキュリティ.NET Framework のセキュリティ
プラットフォームプラットフォーム
バージョン情報バージョン情報
参照参照
関連項目
IsolatedStorageFileStream クラス
IsolatedStorageFileStream メンバ
System.IO.IsolatedStorage 名前空間

IsolatedStorageFileStream コンストラクタ

IsolatedStorageFileStream クラスの新しいインスタンスを初期化します。IsolatedStorageFileStream を開く唯一の方法は、そのコンストラクタの 1 つを使用することです。
オーバーロードの一覧オーバーロードの一覧

名前 説明
IsolatedStorageFileStream (String, FileMode) 指定した mode で、path によって指定されたファイルへのアクセスを与える IsolatedStorageFileStream オブジェクトの新しいインスタンスを初期化します。
IsolatedStorageFileStream (String, FileMode, FileAccess) mode に指定したモードで、path で指定したファイルへの、access に指定した種類のアクセスを提供する、IsolatedStorageFileStream クラスの新しいインスタンスを初期化します。
IsolatedStorageFileStream (String, FileMode, IsolatedStorageFile) mode で指定したモード、isf で指定した IsolatedStorageFile のコンテキストを使用して、path で指定したファイルへのアクセスを提供する IsolatedStorageFileStream クラスの新しいインスタンスを初期化します。
IsolatedStorageFileStream (String, FileMode, FileAccess, FileShare) mode で指定したモード、share で指定した共有モードを使用して、path で指定したファイルへの、access で指定した種類のアクセスを提供する IsolatedStorageFileStream クラスの新しいインスタンスを初期化します。
IsolatedStorageFileStream (String, FileMode, FileAccess, IsolatedStorageFile) mode で指定したモード、isf で指定した IsolatedStorageFile のコンテキストを使用して、path で指定したファイルへの、access で指定した種類のアクセスを提供する IsolatedStorageFileStream クラスの新しいインスタンスを初期化します。
IsolatedStorageFileStream (String, FileMode, FileAccess, FileShare, Int32) mode で指定したモード、share で指定したファイル共有モード、buffersize で指定したバッファ サイズを使用して、path で指定したファイルへの、access で指定した種類のアクセスを提供する IsolatedStorageFileStream クラスの新しいインスタンスを初期化します。
IsolatedStorageFileStream (String, FileMode, FileAccess, FileShare, IsolatedStorageFile) mode で指定したモード、share で指定したファイル共有モード、isf で指定した IsolatedStorageFile のコンテキストを使用して、path で指定したファイルへの、access で指定した種類のアクセスを提供する IsolatedStorageFileStream クラスの新しいインスタンスを初期化します。
IsolatedStorageFileStream (String, FileMode, FileAccess, FileShare, Int32, IsolatedStorageFile) mode で指定したモード、share で指定したファイル共有モード、buffersize で指定したバッファ サイズ、isf で指定した IsolatedStorageFile のコンテキストを使用して、path で指定したファイルへの、access で指定した種類のアクセスを提供する IsolatedStorageFileStream クラスの新しいインスタンスを初期化します。
参照参照

関連項目

IsolatedStorageFileStream クラス
IsolatedStorageFileStream メンバ
System.IO.IsolatedStorage 名前空間

IsolatedStorageFileStream コンストラクタ (String, FileMode, FileAccess, IsolatedStorageFile)

mode で指定したモード、isf で指定した IsolatedStorageFile のコンテキストを使用して、path で指定したファイルへの、access で指定した種類のアクセスを提供する IsolatedStorageFileStream クラスの新しいインスタンスを初期化します。

名前空間: System.IO.IsolatedStorage
アセンブリ: mscorlib (mscorlib.dll 内)
構文構文

Public Sub New ( _
    path As String, _
    mode As FileMode, _
    access As FileAccess, _
    isf As IsolatedStorageFile _
)
Dim path As String
Dim mode As FileMode
Dim access As FileAccess
Dim isf As IsolatedStorageFile

Dim instance As New IsolatedStorageFileStream(path,
 mode, access, isf)
public IsolatedStorageFileStream (
    string path,
    FileMode mode,
    FileAccess access,
    IsolatedStorageFile isf
)
public:
IsolatedStorageFileStream (
    String^ path, 
    FileMode mode, 
    FileAccess access, 
    IsolatedStorageFile^ isf
)
public IsolatedStorageFileStream (
    String path, 
    FileMode mode, 
    FileAccess access, 
    IsolatedStorageFile isf
)
public function IsolatedStorageFileStream (
    path : String, 
    mode : FileMode, 
    access : FileAccess, 
    isf : IsolatedStorageFile
)

パラメータ

path

分離ストレージ内でのファイルの相対パス。

mode

FileMode 値の 1 つ。

access

FileAccess 値のビットごとの組み合わせ。

isf

IsolatedStorageFileStream を開くために使用する IsolatedStorageFile。

例外例外
例外の種類条件

ArgumentException

path の形式が正しくありません。

ArgumentNullException

path が null 参照 (Visual Basic では Nothing) です。

FileNotFoundException

mode に Open が設定されていますが、ファイルが見つかりません。

IsolatedStorageException

isf はクォータを持っていません。

解説解説
使用例使用例

このコンストラクタの使用方法については、次のコード例を参照してください。この例のコンテキスト全体については、IsolatedStorageFileStream の概要を参照してください。

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

.NET Framework のセキュリティ.NET Framework のセキュリティ
プラットフォームプラットフォーム
バージョン情報バージョン情報
参照参照
関連項目
IsolatedStorageFileStream クラス
IsolatedStorageFileStream メンバ
System.IO.IsolatedStorage 名前空間

IsolatedStorageFileStream コンストラクタ (String, FileMode, FileAccess)

mode に指定したモードで、path で指定したファイルへの、access に指定した種類のアクセスを提供する、IsolatedStorageFileStream クラスの新しいインスタンスを初期化します。

名前空間: System.IO.IsolatedStorage
アセンブリ: mscorlib (mscorlib.dll 内)
構文構文

Public Sub New ( _
    path As String, _
    mode As FileMode, _
    access As FileAccess _
)
Dim path As String
Dim mode As FileMode
Dim access As FileAccess

Dim instance As New IsolatedStorageFileStream(path,
 mode, access)
public IsolatedStorageFileStream (
    string path,
    FileMode mode,
    FileAccess access
)
public:
IsolatedStorageFileStream (
    String^ path, 
    FileMode mode, 
    FileAccess access
)
public IsolatedStorageFileStream (
    String path, 
    FileMode mode, 
    FileAccess access
)
public function IsolatedStorageFileStream (
    path : String, 
    mode : FileMode, 
    access : FileAccess
)

パラメータ

path

分離ストレージ内でのファイルの相対パス。

mode

FileMode 値の 1 つ。

access

FileAccess 値のビットごとの組み合わせ。

例外例外
例外の種類条件

ArgumentException

path の形式が正しくありません。

ArgumentNullException

path が null 参照 (Visual Basic では Nothing) です。

FileNotFoundException

mode に Open が設定されていますが、ファイルが見つかりません。

解説解説
.NET Framework のセキュリティ.NET Framework のセキュリティ
プラットフォームプラットフォーム
バージョン情報バージョン情報
参照参照
関連項目
IsolatedStorageFileStream クラス
IsolatedStorageFileStream メンバ
System.IO.IsolatedStorage 名前空間

IsolatedStorageFileStream プロパティ


パブリック プロパティパブリック プロパティ

  名前 説明
パブリック プロパティ CanRead オーバーライドされます。 ファイルを読み取ることができるかどうかを示す Boolean 値を取得します。
パブリック プロパティ CanSeek オーバーライドされます。 シーク操作をサポートしているかどうかを示す Boolean 値を取得します。
パブリック プロパティ CanTimeout  現在のストリームがタイムアウトできるかどうかを決定する値を取得します。 ( Stream から継承されます。)
パブリック プロパティ CanWrite オーバーライドされます。 ファイルに書き込むことができるかどうかを示す Boolean 値を取得します。
パブリック プロパティ Handle オーバーライドされます。 現在の IsolatedStorageFileStream オブジェクトによってカプセル化されるファイルのファイル ハンドルを取得します。IsolatedStorageFileStream オブジェクトではこのプロパティへのアクセスは許可されておらず、IsolatedStorageException がスローされます。
パブリック プロパティ IsAsync オーバーライドされます。 IsolatedStorageFileStream オブジェクトが非同期的に開かれたか、同期的に開かれたかを示す Boolean 値を取得します。
パブリック プロパティ Length オーバーライドされます。 IsolatedStorageFileStream オブジェクトの長さを取得します。
パブリック プロパティ Name  コンストラクタに渡された FileStream の名前を取得します。 ( FileStream から継承されます。)
パブリック プロパティ Position オーバーライドされます。 現在の IsolatedStorageFileStream オブジェクトの現在位置を取得するか、指定した値に設定します。
パブリック プロパティ ReadTimeout  ストリームがタイムアウト前に読み取りを試行する期間を決定する値を取得または設定します。 ( Stream から継承されます。)
パブリック プロパティ SafeFileHandle オーバーライドされます。 現在の IsolatedStorageFileStream オブジェクトによってカプセル化されるファイルのオペレーティング システム ファイル ハンドルを表す SafeFileHandle オブジェクトを取得します。
パブリック プロパティ WriteTimeout  ストリームがタイムアウト前に書き込みを試行する期間を決定する値を取得または設定します。 ( Stream から継承されます。)
参照参照

関連項目

IsolatedStorageFileStream クラス
System.IO.IsolatedStorage 名前空間

IsolatedStorageFileStream メソッド


パブリック メソッドパブリック メソッド

( プロテクト メソッド も参照)
  名前 説明
パブリック メソッド BeginRead オーバーライドされます。 非同期の読み取りを開始します。
パブリック メソッド BeginWrite オーバーライドされます。 非同期の書き込みを開始します。
パブリック メソッド Close  現在のストリームを閉じ、現在のストリームに関連付けられているすべてのリソース (ソケット、ファイル ハンドルなど) を解放します。 ( Stream から継承されます。)
パブリック メソッド CreateObjRef  リモート オブジェクトとの通信に使用するプロキシの生成に必要な情報をすべて格納しているオブジェクトを作成します。 ( MarshalByRefObject から継承されます。)
パブリック メソッド Dispose オーバーロードされます。  
パブリック メソッド EndRead オーバーライドされます。 非同期読み込みリクエストの保留状態を終了します。
パブリック メソッド EndWrite オーバーライドされます。 非同期の書き込みを終了します。
パブリック メソッド Equals  オーバーロードされます。 2 つの Object インスタンスが等しいかどうかを判断します。 ( Object から継承されます。)
パブリック メソッド Flush オーバーライドされます。 バッファの現在の状態でファイルを更新してから、バッファをクリアします。
パブリック メソッド GetAccessControl  現在の FileStream オブジェクトが示すファイルのアクセス制御リスト (ACL: Access Control List) エントリをカプセル化する FileSecurity オブジェクトを取得します。 ( FileStream から継承されます。)
パブリック メソッド GetHashCode  特定の型のハッシュ関数として機能します。GetHashCode は、ハッシュ アルゴリズムや、ハッシュ テーブルのようなデータ構造での使用に適しています。 ( Object から継承されます。)
パブリック メソッド GetLifetimeService  対象のインスタンスの有効期間ポリシーを制御する、現在の有効期間サービス オブジェクトを取得します。 ( MarshalByRefObject から継承されます。)
パブリック メソッド GetType  現在のインスタンスの Type を取得します。 ( Object から継承されます。)
パブリック メソッド InitializeLifetimeService  対象のインスタンスの有効期間ポリシーを制御する、有効期間サービス オブジェクトを取得します。 ( MarshalByRefObject から継承されます。)
パブリック メソッド Lock  読み取りアクセスを許可している間に他のプロセスによって FileStream が変更されるのを防ぎます。 ( FileStream から継承されます。)
パブリック メソッド Read オーバーライドされます。 現在のバッファ内の IsolatedStorageFileStream オブジェクトから配列にバイトをコピーします。
パブリック メソッド ReadByte オーバーライドされます。 分離ストレージで IsolatedStorageFileStream オブジェクトから 1 バイトを読み取ります。
パブリック メソッド ReferenceEquals  指定した複数の Object インスタンスが同一かどうかを判断します。 ( Object から継承されます。)
パブリック メソッド Seek オーバーライドされます。 IsolatedStorageFileStream オブジェクトの現在位置を特定の値に設定します。
パブリック メソッド SetAccessControl  FileSecurity オブジェクトが示すアクセス制御リスト (ACL) エントリを、現在の FileStream オブジェクトが示すファイルに適用します。 ( FileStream から継承されます。)
パブリック メソッド SetLength オーバーライドされます。 IsolatedStorageFileStream オブジェクトの長さを指定した value に設定します。
パブリック メソッド Synchronized  指定した Stream オブジェクトをラップするスレッド セーフな (同期された) ラッパーを作成します。 ( Stream から継承されます。)
パブリック メソッド ToString  現在の Object を表す String を返します。 ( Object から継承されます。)
パブリック メソッド Unlock  他のプロセスにより以前にロックされたファイルの全部または一部へのアクセスを許可します。 ( FileStream から継承されます。)
パブリック メソッド Write オーバーライドされます。 バイト配列から読み取ったデータを使用して、IsolatedStorageFileStream オブジェクトにバイトのブロックを書き込みます。
パブリック メソッド WriteByte オーバーライドされます。 IsolatedStorageFileStream オブジェクトに 1 バイトを書き込みます。
プロテクト メソッドプロテクト メソッド
参照参照

関連項目

IsolatedStorageFileStream クラス
System.IO.IsolatedStorage 名前空間

IsolatedStorageFileStream メンバ

分離ストレージ内のファイルを公開します。

IsolatedStorageFileStream データ型で公開されるメンバを以下の表に示します。


パブリック コンストラクタパブリック コンストラクタ
  名前 説明
パブリック メソッド IsolatedStorageFileStream オーバーロードされます。 IsolatedStorageFileStream クラスの新しいインスタンスを初期化します。IsolatedStorageFileStream を開く唯一の方法は、そのコンストラクタの 1 つを使用することです。
パブリック プロパティパブリック プロパティ
  名前 説明
パブリック プロパティ CanRead オーバーライドされます。 ファイルを読み取ることができるかどうかを示す Boolean 値を取得します。
パブリック プロパティ CanSeek オーバーライドされます。 シーク操作をサポートしているかどうかを示す Boolean 値を取得します。
パブリック プロパティ CanTimeout  現在のストリームがタイムアウトできるかどうかを決定する値を取得します。(Stream から継承されます。)
パブリック プロパティ CanWrite オーバーライドされます。 ファイルに書き込むことができるかどうかを示す Boolean 値を取得します。
パブリック プロパティ Handle オーバーライドされます。 現在の IsolatedStorageFileStream オブジェクトによってカプセル化されるファイルのファイル ハンドルを取得します。IsolatedStorageFileStream オブジェクトではこのプロパティへのアクセスは許可されておらず、IsolatedStorageException がスローされます。
パブリック プロパティ IsAsync オーバーライドされます。 IsolatedStorageFileStream オブジェクトが非同期的に開かれたか、同期的に開かれたかを示す Boolean 値を取得します。
パブリック プロパティ Length オーバーライドされます。 IsolatedStorageFileStream オブジェクトの長さを取得します。
パブリック プロパティ Name  コンストラクタに渡された FileStream の名前を取得します。(FileStream から継承されます。)
パブリック プロパティ Position オーバーライドされます。 現在の IsolatedStorageFileStream オブジェクトの現在位置を取得するか、指定した値に設定します。
パブリック プロパティ ReadTimeout  ストリームがタイムアウト前に読み取りを試行する期間を決定する値を取得または設定します。 (Stream から継承されます。)
パブリック プロパティ SafeFileHandle オーバーライドされます。 現在の IsolatedStorageFileStream オブジェクトによってカプセル化されるファイルのオペレーティング システム ファイル ハンドルを表す SafeFileHandle オブジェクトを取得します。
パブリック プロパティ WriteTimeout  ストリームがタイムアウト前に書き込みを試行する期間を決定する値を取得または設定します。 (Stream から継承されます。)
パブリック メソッドパブリック メソッド
( プロテクト メソッド も参照)
  名前 説明
パブリック メソッド BeginRead オーバーライドされます。 非同期の読み取りを開始します。
パブリック メソッド BeginWrite オーバーライドされます。 非同期の書き込みを開始します。
パブリック メソッド Close  現在のストリームを閉じ、現在のストリームに関連付けられているすべてのリソース (ソケット、ファイル ハンドルなど) を解放します。 (Stream から継承されます。)
パブリック メソッド CreateObjRef  リモート オブジェクトとの通信に使用するプロキシの生成に必要な情報をすべて格納しているオブジェクトを作成します。 (MarshalByRefObject から継承されます。)
パブリック メソッド Dispose オーバーロードされます。  
パブリック メソッド EndRead オーバーライドされます。 非同期読み込みリクエストの保留状態を終了します。
パブリック メソッド EndWrite オーバーライドされます。 非同期の書き込みを終了します。
パブリック メソッド Equals  オーバーロードされます。 2 つの Object インスタンスが等しいかどうかを判断します。 (Object から継承されます。)
パブリック メソッド Flush オーバーライドされます。 バッファの現在の状態でファイルを更新してから、バッファをクリアします。
パブリック メソッド GetAccessControl  現在の FileStream オブジェクトが示すファイルのアクセス制御リスト (ACL: Access Control List) エントリをカプセル化する FileSecurity オブジェクトを取得します。 (FileStream から継承されます。)
パブリック メソッド GetHashCode  特定の型のハッシュ関数として機能します。GetHashCode は、ハッシュ アルゴリズムや、ハッシュ テーブルのようなデータ構造での使用に適しています。 (Object から継承されます。)
パブリック メソッド GetLifetimeService  対象のインスタンスの有効期間ポリシーを制御する、現在の有効期間サービス オブジェクトを取得します。 (MarshalByRefObject から継承されます。)
パブリック メソッド GetType  現在のインスタンスの Type を取得します。 (Object から継承されます。)
パブリック メソッド InitializeLifetimeService  対象のインスタンスの有効期間ポリシーを制御する、有効期間サービス オブジェクトを取得します。 (MarshalByRefObject から継承されます。)
パブリック メソッド Lock  読み取りアクセスを許可している間に他のプロセスによって FileStream が変更されるのを防ぎます。 (FileStream から継承されます。)
パブリック メソッド Read オーバーライドされます。 現在のバッファ内の IsolatedStorageFileStream オブジェクトから配列にバイトをコピーします。
パブリック メソッド ReadByte オーバーライドされます。 分離ストレージで IsolatedStorageFileStream オブジェクトから 1 バイトを読み取ります。
パブリック メソッド ReferenceEquals  指定した複数の Object インスタンスが同一かどうかを判断します。 (Object から継承されます。)
パブリック メソッド Seek オーバーライドされます。 IsolatedStorageFileStream オブジェクトの現在位置を特定の値に設定します。
パブリック メソッド SetAccessControl  FileSecurity オブジェクトが示すアクセス制御リスト (ACL) エントリを、現在の FileStream オブジェクトが示すファイルに適用します。 (FileStream から継承されます。)
パブリック メソッド SetLength オーバーライドされます。 IsolatedStorageFileStream オブジェクトの長さを指定した value に設定します。
パブリック メソッド Synchronized  指定した Stream オブジェクトをラップするスレッド セーフな (同期された) ラッパーを作成します。 (Stream から継承されます。)
パブリック メソッド ToString  現在の Object を表す String を返します。 (Object から継承されます。)
パブリック メソッド Unlock  他のプロセスにより以前にロックされたファイルの全部または一部へのアクセスを許可します。 (FileStream から継承されます。)
パブリック メソッド Write オーバーライドされます。 バイト配列から読み取ったデータを使用して、IsolatedStorageFileStream オブジェクトにバイトのブロックを書き込みます。
パブリック メソッド WriteByte オーバーライドされます。 IsolatedStorageFileStream オブジェクトに 1 バイトを書き込みます。
プロテクト メソッドプロテクト メソッド
参照参照

関連項目

IsolatedStorageFileStream クラス
System.IO.IsolatedStorage 名前空間



英和和英テキスト翻訳

英語⇒日本語日本語⇒英語

辞書ショートカット

すべての辞書の索引

「IsolatedStorageFileStream」の関連用語

IsolatedStorageFileStreamのお隣キーワード
検索ランキング

   

英語⇒日本語
日本語⇒英語
   



IsolatedStorageFileStreamのページの著作権

   
日本マイクロソフト株式会社日本マイクロソフト株式会社
© 2026 Microsoft.All rights reserved.

©2026 GRAS Group, Inc.RSS