IsolatedStorageFile.Remove Metod

Definition

Tar bort det isolerade lagringsomfånget och allt dess innehåll.

Överlagringar

Name Description
Remove()

Tar bort det isolerade lagringsomfånget och allt dess innehåll.

Remove(IsolatedStorageScope)

Tar bort det angivna isolerade lagringsomfånget för alla identiteter.

Remove()

Tar bort det isolerade lagringsomfånget och allt dess innehåll.

public:
 override void Remove();
public override void Remove();
override this.Remove : unit -> unit
Public Overrides Sub Remove ()

Undantag

Det går inte att ta bort det isolerade arkivet.

Exempel

I följande kodexempel används Remove metoden för att ta bort den isolerade lagringsfilen när dess innehåll har tömts. Exemplet How to: Delete Stores in Isolated Storage (Så här gör du: Ta bort butiker i isolerad lagring ) visar också hur metoden används Remove .

    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());
}
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

Kommentarer

Caution

Den här metoden tar oåterkalleligen bort hela omfånget och alla inneslutna kataloger och filer.

Om någon av katalogerna eller filerna i arkivet används misslyckas borttagningsförsöket för arkivet och arkivet markeras för borttagning. Eventuella efterföljande försök att ändra arkivet genererar en IsolatedStorageException.

Se även

Gäller för

Remove(IsolatedStorageScope)

Tar bort det angivna isolerade lagringsomfånget för alla identiteter.

public:
 static void Remove(System::IO::IsolatedStorage::IsolatedStorageScope scope);
public static void Remove(System.IO.IsolatedStorage.IsolatedStorageScope scope);
static member Remove : System.IO.IsolatedStorage.IsolatedStorageScope -> unit
Public Shared Sub Remove (scope As IsolatedStorageScope)

Parametrar

scope
IsolatedStorageScope

En bitvis kombination av IsolatedStorageScope värdena.

Undantag

Det går inte att ta bort det isolerade arkivet.

Kommentarer

Caution

Den här metoden tar oåterkalleligen bort hela omfånget och alla inneslutna kataloger och filer.

Om någon av katalogerna eller filerna i arkivet används misslyckas borttagningsförsöket för arkivet och arkivet markeras för borttagning. Eventuella efterföljande försök att ändra arkivet genererar en IsolatedStorageException.

Se även

Gäller för