격리 된 저장소의 작성된 디렉토리에서 작성된 파일을 읽으려고합니다. 파일이 실제로 작성 중입니다. 이 예외가 그것을 읽을 때 그러나 "작업 IsolatedStorageFileStream에 허용되지 않습니다."... 격리 된 저장소에서 작성된 디렉토리의 파일 읽기
using (IsolatedStorageFile storage = IsolatedStorageFile.GetUserStoreForApplication())
{
if (!storage.DirectoryExists("CourseworkDirectory"))
storage.CreateDirectory("CourseworkDirectory");
XElement Coursework = new XElement(CourseworkID);
XDocument _doc = new XDocument(new XDeclaration("1.0", "utf-8", "yes"), Coursework);
IsolatedStorageFileStream location = new IsolatedStorageFileStream("CourseworkDirectory\\"+CourseworkID, System.IO.FileMode.Create, storage);
StreamWriter file = new StreamWriter(location);
_doc.Save(file);//saving the XML document as the file
file.Close();
file.Dispose();//disposing the file
location.Dispose();
}
파일을 읽기 ....
using (IsolatedStorageFile storage = IsolatedStorageFile.GetUserStoreForApplication())
{
string searchpath = System.IO.Path.Combine("CourseworkDirectory", "*.*");
foreach (string filename in storage.GetFileNames(searchpath))
{
XElement _xml;
IsolatedStorageFileStream location = new IsolatedStorageFileStream(filename, System.IO.FileMode.Open, storage);
그것은 실제로 파일 이름을 얻고있다 그러나이 시점에서는 예외가 있습니다.
당신은 storage.OpenFile (fileName, FileMode.Open, FileAccess.Read)을 시도 했습니까? –
예 ... 실제로 파일 이름을보고 있지만 동일한 문제가 있습니다. – user1619553
문제는 내가 만든 디렉토리와 관련이 있습니다 ... IsolatedStorageFile을 사용하려고 시도했을 때 매우 효과적이었습니다. – user1619553