【问题标题】:How to delete file from isolated Storage如何从隔离存储中删除文件
【发布时间】:2014-03-20 14:48:33
【问题描述】:

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

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());
        }
    }

请让我知道我在哪里做错了。 提前谢谢..

错误信息:-

【问题讨论】:

  • 尝试在文件夹前添加/
  • 你得到什么错误信息或异常
  • 大家好!!在这里我附上了一个截图..请参考这个..
  • 嗨@Ku6opr ..尝试了你的建议..直到现在发生同样的错误..
  • 在哪一行代码中出现错误?我成功删除了您的代码和文件。

标签: c# windows-phone-7 isolatedstorage


【解决方案1】:

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

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2013-04-02
    • 1970-01-01
    • 2022-01-02
    • 2011-01-04
    相关资源
    最近更新 更多