IsolatedStorageFile::DeleteDirectory Method (String^)
.NET Framework (current version)
Deletes a directory in the isolated storage scope.
Assembly: mscorlib (in mscorlib.dll)
Parameters
- dir
-
Type:
System::String^
The relative path of the directory to delete within the isolated storage scope.
| Exception | Condition |
|---|---|
| IsolatedStorageException | The directory could not be deleted. |
| ArgumentNullException | The directory path was null. |
A directory must be empty before it is deleted. The deleted directory cannot be recovered once deleted.
The How to: Delete Files and Directories in Isolated Storage example demonstrates the use of the DeleteDirectory method.
// This method deletes directories in the specified Isolated Storage, after first // deleting the files they contain. In this example, the Archive directory is deleted. // There should be no other directories in this Isolated Storage. void DeleteDirectories() { try { IsolatedStorageFile^ isoFile = IsolatedStorageFile::GetStore( static_cast<IsolatedStorageScope>(IsolatedStorageScope::User | IsolatedStorageScope::Assembly | IsolatedStorageScope::Domain), System::Security::Policy::Url::typeid, System::Security::Policy::Url::typeid ); array<String^>^dirNames = isoFile->GetDirectoryNames( "*" ); array<String^>^fileNames = isoFile->GetFileNames( "Archive\\*" ); // Delete the current files within the Archive directory. if ( fileNames->Length > 0 ) { for ( int i = 0; i < fileNames->Length; ++i ) { //delete files isoFile->DeleteFile( String::Concat("Archive\\", fileNames[ i ]) ); } fileNames = isoFile->GetFileNames( "Archive\\*" ); } if ( dirNames->Length > 0 ) { for ( int i = 0; i < dirNames->Length; ++i ) { // Delete the Archive directory. isoFile->DeleteDirectory( dirNames[ i ] ); } } dirNames = isoFile->GetDirectoryNames( "*" ); isoFile->Remove(); } catch ( Exception^ e ) { Console::WriteLine( e->ToString() ); } }
IsolatedStorageFilePermissionReflectionPermission
for accessing the isolated storage scope.
when invoked late-bound through mechanisms such as Type::InvokeMember. Associated enumeration: ReflectionPermissionFlag::MemberAccess
Universal Windows Platform
Available since 10
.NET Framework
Available since 1.1
Silverlight
Available since 2.0
Windows Phone Silverlight
Available since 7.0
Available since 10
.NET Framework
Available since 1.1
Silverlight
Available since 2.0
Windows Phone Silverlight
Available since 7.0
Show: