Windows apps
Collapse the table of content
Expand the table of content
Information
The topic you requested is included in another documentation set. For convenience, it's displayed below. Choose Switch to see the topic in its original location.

IsolatedStorageFile.DeleteFile Method (String)

 

Deletes a file in the isolated storage scope.

Namespace:   System.IO.IsolatedStorage
Assembly:  mscorlib (in mscorlib.dll)

public void DeleteFile(
	string file
)

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.

public void DeleteFiles()
{
    try
    {
        IsolatedStorageFile isoFile = IsolatedStorageFile.GetStore(IsolatedStorageScope.User |
            IsolatedStorageScope.Assembly |
            IsolatedStorageScope.Domain,
            typeof(System.Security.Policy.Url),
            typeof(System.Security.Policy.Url));

        String[] dirNames = isoFile.GetDirectoryNames("*");
        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]);
            }
            // Confirm that no files remain.
            fileNames = isoFile.GetFileNames("*");
        }
    }
    catch (Exception e)
    {
        Console.WriteLine(e.ToString());
    }

}

IsolatedStorageFilePermission

for accessing files in the isolated storage scope.

ReflectionPermission

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
Return to top
Show:
© 2016 Microsoft