さて、可能なすべての解決策を検索して試しましたが、それでも例外がスローされます。どんな助けでも素晴らしいでしょう。
public void SaveOrReplace(string fileContent)
{
using (IsolatedStorageFile storage = IsolatedStorageFile.GetUserStoreForApplication())
{
if (!storage.DirectoryExists("FX"))
storage.CreateDirectory("FX");
if (storage.FileExists(FilePath))
storage.DeleteFile(FilePath);
//when I debug, it code does not get past here
// when I remove this first using no exception, but of course I can't write some text to the file
using (IsolatedStorageFileStream fileStream = storage.CreateFile(FilePath))
{
using (StreamWriter writer = new StreamWriter(fileStream))
{
writer.Write(fileContent);
fileStream.Dispose();
}
}
}
}
参考までにスタック トレースを参照してください。
at System.IO.IsolatedStorage.IsolatedStorageFileStream..ctor(String path, FileMode mode, FileAccess access, FileShare share, Int32 bufferSize, IsolatedStorageFile isf)
at System.IO.IsolatedStorage.IsolatedStorageFile.CreateFile(String path)
at FXNews.Models.FFNewsProvider.SaveOrReplace(String fileContent)
at FXNews.Models.FFNewsProvider.<Load>d__b.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at System.Runtime.CompilerServices.TaskAwaiter`1.GetResult()
at FXNews.Models.FFNewsProvider.<GetNewsCollection>d__5.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at System.Runtime.CompilerServices.TaskAwaiter`1.GetResult()
at FXNews.ViewModels.PivotPageViewModel.<GetAllNews>d__0.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at System.Runtime.CompilerServices.TaskAwaiter`1.GetResult()
at FXNews.Views.PivotPage.<OnNavigatedTo>d__2.MoveNext()
この場合、何が間違っていますか?