IsolatedStorageFile::DeleteFile Method (String^)
.NET Framework (current version)
Deletes a file in the isolated storage scope.
Assembly: mscorlib (in mscorlib.dll)
Parameters
- file
-
Type:
System::String^
The relative path of the file to delete within the isolated storage scope.
| Exception | Condition |
|---|---|
| IsolatedStorageException | The target file is open or the path is incorrect. |
| ArgumentNullException | The file path is null. |
The deleted file cannot be recovered once deleted.
The How to: Delete Files and Directories in Isolated Storage example demonstrates the use of the DeleteFile method.
The following code example uses the DeleteFile method to delete a number of files in isolated storage.
void DeleteFiles() { 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( "*" ); // 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 ) { //Delete the files. isoFile->DeleteFile( fileNames[ i ] ); } fileNames = isoFile->GetFileNames( "*" ); } isoFile->Close(); } catch ( Exception^ e ) { Console::WriteLine( e->ToString() ); } }
IsolatedStorageFilePermissionReflectionPermission
for accessing files in 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: