Procedure: Winkels verwijderen in Geïsoleerde opslag
De IsolatedStorageFile klasse biedt twee methoden voor het verwijderen van geïsoleerde opslagbestanden:
De instantiemethode Remove() neemt geen argumenten en verwijdert het archief dat deze aanroept. Er zijn geen machtigingen vereist voor deze bewerking. Elke code die toegang heeft tot het archief, kan alle of alle gegevens erin verwijderen.
De statische methode Remove(IsolatedStorageScope) neemt de User opsommingswaarde op en verwijdert alle winkels voor de gebruiker die de code uitvoert. Voor deze bewerking is een machtiging vereist IsolatedStorageFilePermission voor de AdministerIsolatedStorageByUser waarde.
Opmerking
In het volgende codevoorbeeld ziet u het gebruik van de statische methoden en instantiemethoden Remove . De klasse verkrijgt twee winkels; de ene is geïsoleerd voor gebruiker en assembly en de andere is geïsoleerd voor gebruiker, domein en assembly. Het gebruikers-, domein- en assemblyarchief wordt vervolgens verwijderd door de Remove() methode van het geïsoleerde opslagbestand isoStore1
aan te roepen. Vervolgens worden alle resterende winkels voor de gebruiker verwijderd door de statische methode Remove(IsolatedStorageScope)aan te roepen.
using namespace System;
using namespace System::IO::IsolatedStorage;
public ref class DeletingStores
{
public:
static void Main()
{
// Get a new isolated store for this user, domain, and assembly.
// Put the store into an IsolatedStorageFile object.
IsolatedStorageFile^ isoStore1 = IsolatedStorageFile::GetStore(IsolatedStorageScope::User |
IsolatedStorageScope::Domain | IsolatedStorageScope::Assembly, (Type ^)nullptr, (Type ^)nullptr);
Console::WriteLine("A store isolated by user, assembly, and domain has been obtained.");
// Get a new isolated store for user and assembly.
// Put that store into a different IsolatedStorageFile object.
IsolatedStorageFile^ isoStore2 = IsolatedStorageFile::GetStore(IsolatedStorageScope::User |
IsolatedStorageScope::Assembly, (Type ^)nullptr, (Type ^)nullptr);
Console::WriteLine("A store isolated by user and assembly has been obtained.");
// The Remove method deletes a specific store, in this case the
// isoStore1 file.
isoStore1->Remove();
Console::WriteLine("The user, domain, and assembly isolated store has been deleted.");
// This static method deletes all the isolated stores for this user.
IsolatedStorageFile::Remove(IsolatedStorageScope::User);
Console::WriteLine("All isolated stores for this user have been deleted.");
} // End of Main.
};
int main()
{
DeletingStores::Main();
}
using System;
using System.IO.IsolatedStorage;
public class DeletingStores
{
public static void Main()
{
// Get a new isolated store for this user, domain, and assembly.
// Put the store into an IsolatedStorageFile object.
IsolatedStorageFile isoStore1 = IsolatedStorageFile.GetStore(IsolatedStorageScope.User |
IsolatedStorageScope.Domain | IsolatedStorageScope.Assembly, null, null);
Console.WriteLine("A store isolated by user, assembly, and domain has been obtained.");
// Get a new isolated store for user and assembly.
// Put that store into a different IsolatedStorageFile object.
IsolatedStorageFile isoStore2 = IsolatedStorageFile.GetStore(IsolatedStorageScope.User |
IsolatedStorageScope.Assembly, null, null);
Console.WriteLine("A store isolated by user and assembly has been obtained.");
// The Remove method deletes a specific store, in this case the
// isoStore1 file.
isoStore1.Remove();
Console.WriteLine("The user, domain, and assembly isolated store has been deleted.");
// This static method deletes all the isolated stores for this user.
IsolatedStorageFile.Remove(IsolatedStorageScope.User);
Console.WriteLine("All isolated stores for this user have been deleted.");
} // End of Main.
}
Imports System.IO.IsolatedStorage
Public Class DeletingStores
Public Shared Sub Main()
' Get a new isolated store for this user, domain, and assembly.
' Put the store into an IsolatedStorageFile object.
Dim isoStore1 As IsolatedStorageFile = IsolatedStorageFile.GetStore(IsolatedStorageScope.User Or
IsolatedStorageScope.Domain Or IsolatedStorageScope.Assembly, Nothing, Nothing)
Console.WriteLine("A store isolated by user, assembly, and domain has been obtained.")
' Get a new isolated store for user and assembly.
' Put that store into a different IsolatedStorageFile object.
Dim isoStore2 As IsolatedStorageFile = IsolatedStorageFile.GetStore(IsolatedStorageScope.User Or
IsolatedStorageScope.Assembly, Nothing, Nothing)
Console.WriteLine("A store isolated by user and assembly has been obtained.")
' The Remove method deletes a specific store, in this case the
' isoStore1 file.
isoStore1.Remove()
Console.WriteLine("The user, domain, and assembly isolated store has been deleted.")
' This static method deletes all the isolated stores for this user.
IsolatedStorageFile.Remove(IsolatedStorageScope.User)
Console.WriteLine("All isolated stores for this user have been deleted.")
End Sub
End Class