如何从隔离存储中删除文件

时间:2014-03-19 11:53:42

标签: c# windows-phone-7 isolatedstorage

我正在尝试从隔离存储中删除文件。但它返回错误信息给我。我不知道我错在哪里。

public void Delete(string folder, string fileName)
    {
        try
        {
            string path = folder + "\\" + fileName + ".txt";
            string delPath = folder + "/" + fileName + ".txt";
            MessageBox.Show(delPath);
            if (myIsolatedStorage.DirectoryExists(folder))
            {
                if (myIsolatedStorage.FileExists(delPath))
                {
                    myIsolatedStorage.DeleteFile(delPath);
                    MessageBox.Show("File is Deleted..!!");
                }
                else
                    MessageBox.Show("There is no file is exists");
            }
            else
            {
                MessageBox.Show("There is no Folder is exists");
            }

        }
        catch (Exception ex)
        {
            MessageBox.Show(ex.ToString());
        }
    }

请告诉我错误的地方。 提前谢谢..

错误讯息: -

enter image description here

1 个答案:

答案 0 :(得分:1)

也许,您尝试删除的文件仍在使用中。您的应用程序应该没有打开的文件或对您尝试删除的文件的引用。

相关问题