IsolatedStorageFile.Remove 方法

定义

移除独立存储区范围及其所有内容。

重载

Remove()

移除独立存储区范围及其所有内容。

Remove(IsolatedStorageScope)

为所有标识移除指定的独立存储范围。

Remove()

移除独立存储区范围及其所有内容。

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

例外

无法删除独立存储区。

示例

下面的代码示例使用 Remove 该方法在内容清空后删除独立存储文件。 How to: Delete Stores in Isolated 存储 example 也演示了该方法Remove的使用。

array<String^>^dirNames = isoFile->GetDirectoryNames( "*" );
array<String^>^fileNames = isoFile->GetFileNames( "*" );

// List directories currently in this Isolated Storage.
if ( dirNames->Length > 0 )
{
   for ( int i = 0; i < dirNames->Length; ++i )
   {
      Console::WriteLine( "Directory Name: {0}", dirNames[ i ] );

   }
}


// 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 )
{
   for ( int i = 0; i < fileNames->Length; ++i )
   {
      Console::WriteLine( "File Name: {0}", fileNames[ i ] );

   }
}
    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

注解

注意

此方法不可撤销地删除整个范围和所有包含的目录和文件。

如果存储中的任何目录或文件正在使用中,则存储的删除尝试将失败,并且存储将被标记为删除。 修改存储的任何后续尝试都引发一个 IsolatedStorageException

另请参阅

适用于

Remove(IsolatedStorageScope)

为所有标识移除指定的独立存储范围。

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)

参数

scope
IsolatedStorageScope

IsolatedStorageScope 值的按位组合。

例外

无法移除独立存储区。

注解

注意

此方法不可撤销地删除整个范围和所有包含的目录和文件。

如果存储中的任何目录或文件正在使用中,则存储的删除尝试将失败,并且存储将被标记为删除。 修改存储的任何后续尝试都引发一个 IsolatedStorageException

另请参阅

适用于