Заметка
Доступ к этой странице требует авторизации. Вы можете попробовать войти в систему или изменить каталог.
Доступ к этой странице требует авторизации. Вы можете попробовать сменить директорию.
Класс IsolatedStorageFile предоставляет два метода удаления изолированных файлов хранилища:
Метод экземпляра Remove() не принимает аргументов и удаляет вызывающее его хранилище. Для этой операции не требуются разрешения. Любой код, к которому можно получить доступ к хранилищу, может удалять любые или все данные внутри него.
Статический метод Remove(IsolatedStorageScope) принимает значение перечисления User и удаляет все хранилища для пользователя, выполняющего код. Для этой операции требуется IsolatedStorageFilePermission разрешение для AdministerIsolatedStorageByUser значения.
Пример
В следующем примере кода демонстрируется использование статических и экземплярных Remove методов. Класс получает два хранилища; Один из них изолирован для пользователя и сборки, а другой изолирован для пользователя, домена и сборки. Затем пользователь, домен и хранилище сборок удаляются путем вызова метода Remove() изолированного хранилища файлов isoStore1. Затем все оставшиеся хранилища для пользователя удаляются путем вызова статического метода Remove(IsolatedStorageScope).
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