IsolatedStorageFile.GetUserStoreForDomain Method
Definition
Important
Some information relates to prerelease product that may be substantially modified before it’s released. Microsoft makes no warranties, express or implied, with respect to the information provided here.
Obtains user-scoped isolated storage corresponding to the application domain identity and assembly identity.
public:
static System::IO::IsolatedStorage::IsolatedStorageFile ^ GetUserStoreForDomain();
public static System.IO.IsolatedStorage.IsolatedStorageFile GetUserStoreForDomain ();
static member GetUserStoreForDomain : unit -> System.IO.IsolatedStorage.IsolatedStorageFile
Public Shared Function GetUserStoreForDomain () As IsolatedStorageFile
Returns
An object corresponding to the IsolatedStorageScope, based on a combination of the application domain identity and the assembly identity.
Exceptions
Sufficient isolated storage permissions have not been granted.
The store failed to open.
-or-
The assembly specified has insufficient permissions to create isolated stores.
-or-
An isolated storage location cannot be initialized.
-or-
The permissions for the application domain cannot be determined.
Examples
The following code example demonstrates the GetUserStoreForDomain method. For the complete context of this example, see the IsolatedStorageFile overview.
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;
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;
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
Remarks
The same assembly code will use different isolated stores when used in the context of different applications.
GetUserStoreForDomain is functionally equivalent to the following code:
isoFile = IsolatedStorageFile::GetStore(IsolatedStorageScope::Assembly |
IsolatedStorageScope::Domain | IsolatedStorageScope::User,
(Type^)nullptr, (Type^)nullptr);
isoFile = IsolatedStorageFile.GetStore(IsolatedStorageScope.Assembly |
IsolatedStorageScope.Domain | IsolatedStorageScope.User,
null, null);
isoFile = IsolatedStorageFile.GetStore(IsolatedStorageScope.Assembly Or _
IsolatedStorageScope.Domain Or IsolatedStorageScope.User, _
Nothing, Nothing)
Different assemblies running within the same application domain always have distinct isolated stores.
Note
GetUserStoreForDomain will return an IsolatedStorageFile object without a quota if the application domain in which the assembly is installed does not have IsolatedStorageFilePermission. Later attempts to create an IsolatedStorageFile object using the IsolatedStorageFile object that does not have a quota will fail with an IsolatedStorageException.
Applies to
See also
Povratne informacije
https://aka.ms/ContentUserFeedback.
Kmalu na voljo: V letu 2024 bomo ukinili storitev Težave v storitvi GitHub kot mehanizem za povratne informacije za vsebino in jo zamenjali z novim sistemom za povratne informacije. Za več informacij si oglejte:Pošlji in prikaži povratne informacije za