IsolatedStorageFile.FileExists(string path)
作品,但StreamReader(string samePath)
不? 我已验证两个路径是相等的。我不知道为什么StreamReader的爆炸IsolatedStorageFile.FileExists(字符串路径)工作,但StreamReader(字符串samePath)不?
List<ProjectObj> ret = new List<ProjectObj>();
IsolatedStorageFile file = IsolatedStorageFile.GetUserStoreForApplication();
if (!file.DirectoryExists("/projects/")) //trying to validate the dir exists
return ret;
string[] fileNames = file.GetFileNames("/projects/");
foreach (string filename in fileNames)
{
if (!file.FileExists("/projects/" + filename)) //validate just one more time..
continue;
ProjectObj tempProj = new ProjectObj();
//Even with the validation it still breaks right here with the bellow error
StreamReader reader = new StreamReader("/projects/"+filename);
型“System.IO.DirectoryNotFoundException”的异常出现在mscorlib.ni.dll 但在用户代码中没有处理
消息:可能找不到路径 'C:\ projects \ Title_939931883.txt'的一部分。
IsolatedStorageFileStream不允许操作。 –
我已经更新了答案并使用http://stackoverflow.com/questions/8415979/operation-not-permitted-on-isolatedstoragefilestream-error –
修复了第一条使用线上的错误 –