Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/apache-flex/4.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Windows phone 7 尝试写入IsolatedStorageFile时未找到资源ID的定义_Windows Phone 7_Silverlight 4.0_Windows Phone_Isolatedstorage_Streamwriter - Fatal编程技术网

Windows phone 7 尝试写入IsolatedStorageFile时未找到资源ID的定义

Windows phone 7 尝试写入IsolatedStorageFile时未找到资源ID的定义,windows-phone-7,silverlight-4.0,windows-phone,isolatedstorage,streamwriter,Windows Phone 7,Silverlight 4.0,Windows Phone,Isolatedstorage,Streamwriter,我试图向IsolatedStorageFile写入字符串,但得到了IsolatedStorageException,异常中的链接如下: http://www.microsoft.com/getsilverlight/DllResourceIDs/Default.aspx?Version=4.0.50829.0&File=mscorlib.dll&Key=IsolatedStorage_Operation_ISFS 并且声明找不到“资源ID”的定义。我不知道为什么会发生这种异常,

我试图向IsolatedStorageFile写入字符串,但得到了IsolatedStorageException,异常中的链接如下:

http://www.microsoft.com/getsilverlight/DllResourceIDs/Default.aspx?Version=4.0.50829.0&File=mscorlib.dll&Key=IsolatedStorage_Operation_ISFS
并且声明找不到“资源ID”的定义。我不知道为什么会发生这种异常,以下是我的代码:

private void writeListToStorage(List<PlanningItemModel> items)
    {
        IsolatedStorageFile myIsolatedStorageFile = IsolatedStorageFile.GetUserStoreForApplication();
        if(myIsolatedStorageFile.FileExists("Zomerparkfeesten\\" + filePath))
        {
            IsolatedStorageFileStream iStream = myIsolatedStorageFile.OpenFile("Zomerparkfeesten\\" + filePath, FileMode.Open, FileAccess.Write);
            string json = Converter.convertListOfItemsToJson(items);
            StreamWriter writeFile = new StreamWriter(iStream);
            try
            {
                writeFile.WriteLine(json);
                writeFile.Close();
                iStream.Close();
            }
            catch (IOException)
            {
                writeFile.Close();
                iStream.Close();
            }
        }
        else 
        {
            myIsolatedStorageFile.CreateFile("Zomerparkfeesten\\" + filePath);
            this.writeListToStorage(items);
        }
    }
private void writeListToStorage(列表项)
{
IsolatedStorageFile myIsolatedStorageFile=IsolatedStorageFile.GetUserStoreForApplication();
如果(myIsolatedStorageFile.FileExists(“Zomerparkfeesten\\”+filePath))
{
IsolatedStorageFileStream iStream=myIsolatedStorageFile.OpenFile(“Zomerparkfeesten\\”+文件路径,FileMode.Open,FileAccess.Write);
字符串json=Converter.convertListOfItemsToJson(项);
StreamWriter writeFile=新的StreamWriter(iStream);
尝试
{
writeFile.WriteLine(json);
writeFile.Close();
iStream.Close();
}
捕获(IOException)
{
writeFile.Close();
iStream.Close();
}
}
其他的
{
myIsolatedStorageFile.CreateFile(“Zomerparkfeesten\\”+filePath);
这是一个可写的存储(项目);
}
}
有什么想法吗

并且声明找不到“资源ID”的定义

不,不是这么说的。奇怪的问题,可能是因为你说的是荷兰语而不是英语。看起来他们在这个特殊例外的荷兰本地化问题上犯了错误。当我从美国访问该URL时,我得到:

不允许对IsolatedStorageFileStream执行操作

考虑到代码片段,这当然更有意义。除此之外,我无法为您提供更多帮助,最基本的问题是您的程序没有对独立存储的写访问权限。你需要给它访问权限

一种很难诊断的严重故障模式,当您为“filePath”传递一个空字符串时,这段代码总是会以“不允许操作”结束。这将使代码尝试编写一个与现有目录同名的文件,这是不允许的。

尝试使用此代码:

 using (IsolatedStorageFile myIsolatedStorageFile = IsolatedStorageFile.GetUserStoreForApplication())
            {
                if (!myIsolatedStorageFile.DirectoryExists("Zomerparkfeesten"))
                {
                    myIsolatedStorageFile.CreateDirectory("Zomerparkfeesten");
                    myIsolatedStorageFile.CreateFile("Zomerparkfeesten//" + filePath);

                }
                else
                {
                    if (!myIsolatedStorageFile.FileExists("Zomerparkfeesten//" + filePath))
                    {
                        myIsolatedStorageFile.CreateFile("Zomerparkfeesten//" + filePath);
                    }

                }

                using (Stream stream = new IsolatedStorageFileStream("Zomerparkfeesten//" + filePath, FileMode.Append, FileAccess.Write, myIsolatedStorageFile))
                {
                    using (StreamWriter writer = new StreamWriter(stream))
                    {
                        writer.WriteLine("Test");// some your data
                        writer.Close();
                        stream.Close();
                    }
                }

            }

您是否创建了Zomerparkfeesten文件夹?它在哪一行中断?是的,文件夹存在,每当我尝试对MyIsolatedStorage文件执行操作时,它都会中断。我尝试过OpenFile和DeletFile,但每次都会抛出异常。您是否尝试过以下语法(var stream=new IsolatedStorageFileStream(“folder\\”+fileName,FileMode.Create,FileAccess.Write,myIsolatedStorage))好的,我已经实现了它,但它仍然会抛出异常。现在,当我尝试对IsolatedStorageFile执行操作时,它总是抛出异常。感谢您回答这个问题!你知道有没有办法找到英文版的链接?禁用本地化,像我遇到的那样的错误在将来对我没有多大帮助。谢谢你的明确回答!这不起作用,我尝试过安装Hola扩展之类的软件,但它也没有更改错误消息。我更改了Microsoft站点本身的语言设置,它更改了错误消息。奇怪的不方便的错误。最好的办法就是把它修好。我报告了错误: