不允许操作上IsolatedStorageFileStream错误 [英] Operation not permitted on IsolatedStorageFileStream error
问题描述
它给操作不允许在IsolatedStorageFileStream
错误,当我试图保存在FILESTREAM FS文件的内容。
VAR appStorage = IsolatedStorageFile.GetUserStoreForApplication();
的String [] =的fileList appStorage.GetFileNames();
使用的foreach(在的fileList字符串文件名)
{
(var文件= appStorage.OpenFile(文件名,FileMode.Open))
{
如果(文件名=__ApplicationSettings!)
{
变种FS =新IsolatedStorageFileStream(文件名,FileMode.Open,FileAccess.Read,appStorage);
串ABC = fs.ToString();
meTextBlock.Text = ABC;
//的MemoryStream毫秒= appStorage.OpenFile(文件名,FileMode.Open,FileAccess.Read);
clientUpload.UploadAsync(SkyDriveFolderId,文件名,FS);
}
}
}
你为什么要加内使用(var文件= appStorage.OpenFile(文件名,FileMode.Open))
?
在我看来,问题是,你打开一个流读取该文件,然后打开另一个,而不关闭前一个!
如果您删除该行(似乎并没有被做任何事情有)应该工作的罚款。
呵呵,和 fs.ToString()
只会让你的类型名称,而不是文件内容;读取文件,使用的StreamReader
与 FS
。
It gives operation not permitted on IsolatedStorageFileStream
error when I try to save the content of the file in the fileStream fs.
var appStorage = IsolatedStorageFile.GetUserStoreForApplication();
string[] fileList = appStorage.GetFileNames();
foreach (string fileName in fileList)
{
using (var file = appStorage.OpenFile(fileName, FileMode.Open))
{
if (fileName != "__ApplicationSettings")
{
var fs = new IsolatedStorageFileStream(fileName, FileMode.Open, FileAccess.Read, appStorage);
string abc = fs.ToString();
meTextBlock.Text = abc;
//MemoryStream ms = appStorage.OpenFile(fileName, FileMode.Open, FileAccess.Read);
clientUpload.UploadAsync(SkyDriveFolderId, fileName, fs);
}
}
}
Why did you add the inner using (var file = appStorage.OpenFile(fileName, FileMode.Open))
?
Seems to me the problem is that you're opening a stream to read the file and then opening another, without closing the previous one!
If you remove that line (seems not to be doing anything there) it should work fine.
Oh, and the fs.ToString()
will only get you the Type name, not the file content; to read the file, use a StreamReader
with the fs
.
这篇关于不允许操作上IsolatedStorageFileStream错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!