IsolatedStorageFile.DeleteFile(String) 메서드

정의

격리된 스토리지 범위에서 파일을 삭제합니다.

public:
 void DeleteFile(System::String ^ file);
public void DeleteFile(string file);
member this.DeleteFile : string -> unit
Public Sub DeleteFile (file As String)

매개 변수

file
String

격리된 스토리지 범위 내에서 삭제할 파일의 상대 경로입니다.

예외

대상 파일이 열려 있거나 경로가 잘못되었습니다.

파일 경로는 .입니다 null.

예제

다음 코드 예제에서는 이 메서드를 DeleteFile 사용하여 격리된 스토리지의 여러 파일을 삭제합니다.

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());
    }
}
Public Sub DeleteFiles()
    Try
        Dim isoFile As IsolatedStorageFile = IsolatedStorageFile.GetStore(IsolatedStorageScope.User Or _
            IsolatedStorageScope.Assembly Or IsolatedStorageScope.Domain, _
            GetType(System.Security.Policy.Url), GetType(System.Security.Policy.Url))
        Dim name As String
        Dim dirNames As String() = isoFile.GetDirectoryNames("*")
        Dim fileNames As String() = 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 Then
            For Each name In fileNames
                ' Delete the files.
                isoFile.DeleteFile(name)
            Next name
            'Confirm no files are left.
            fileNames = isoFile.GetFileNames("*")
        End If
    Catch ex As Exception
        Console.WriteLine(ex.ToString())
    End Try
End Sub

설명

삭제된 파일은 삭제된 후 복구할 수 없습니다.

방법: 격리된 스토리지의 파일 및 디렉터리 삭제 예제에서는 이 메서드를 사용하는 방법을 DeleteFile 보여 줍니다.

적용 대상

추가 정보