IsolatedStorageFile.Remove Method

Definition

Removes the isolated storage scope and all its contents.

Overloads

Remove()

Removes the isolated storage scope and all its contents.

Remove(IsolatedStorageScope)

Removes the specified isolated storage scope for all identities.

Remove()

Source:
IsolatedStorageFile.cs
Source:
IsolatedStorageFile.cs
Source:
IsolatedStorageFile.cs

Removes the isolated storage scope and all its contents.

C#
public override void Remove();

Exceptions

The isolated store cannot be deleted.

Examples

The following code example uses the Remove method to delete the isolated storage file after its contents have been emptied. The How to: Delete Stores in Isolated Storage example also demonstrates the use of the Remove method.

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

Remarks

Caution

This method irrevocably removes the entire scope and all contained directories and files.

If any of the directories or files in the store are in use, the removal attempt for the store fails and the store is marked for removal. Any subsequent attempts to modify the store throw an IsolatedStorageException.

See also

Applies to

.NET 10 and other versions
Product Versions
.NET Core 2.0, Core 2.1, Core 2.2, Core 3.0, Core 3.1, 5, 6, 7, 8, 9, 10
.NET Framework 1.1, 2.0, 3.0, 3.5, 4.0, 4.5, 4.5.1, 4.5.2, 4.6, 4.6.1, 4.6.2, 4.7, 4.7.1, 4.7.2, 4.8, 4.8.1
.NET Standard 2.0, 2.1

Remove(IsolatedStorageScope)

Source:
IsolatedStorageFile.cs
Source:
IsolatedStorageFile.cs
Source:
IsolatedStorageFile.cs

Removes the specified isolated storage scope for all identities.

C#
public static void Remove(System.IO.IsolatedStorage.IsolatedStorageScope scope);

Parameters

scope
IsolatedStorageScope

A bitwise combination of the IsolatedStorageScope values.

Exceptions

The isolated store cannot be removed.

Remarks

Caution

This method irrevocably removes the entire scope and all contained directories and files.

If any of the directories or files in the store are in use, the removal attempt for the store fails and the store is marked for removal. Any subsequent attempts to modify the store throw an IsolatedStorageException.

See also

Applies to

.NET 10 and other versions
Product Versions
.NET Core 2.0, Core 2.1, Core 2.2, Core 3.0, Core 3.1, 5, 6, 7, 8, 9, 10
.NET Framework 1.1, 2.0, 3.0, 3.5, 4.0, 4.5, 4.5.1, 4.5.2, 4.6, 4.6.1, 4.6.2, 4.7, 4.7.1, 4.7.2, 4.8, 4.8.1
.NET Standard 2.0, 2.1