Windows phone 7에서 문제가 발생하여 답변을 찾을 수 없습니다. 텍스트 파일의 내용을 프로젝트 파일에있는 간단한 txt 파일에 쓰려고합니다. StreamWriter를 사용하려고했지만 StreamReader 만 작동하고 IsolatedStorage를 사용하려고 시도했지만 다시 작동하지 않았습니다. 제발, 어쩌면 당신이 나 에게이 문제에 대한 해결책을 찾을 수 있습니까?파일에 어떻게 쓰나요?
편집 : 내가 사용 코드 :
var myStore = IsolatedStorageFile.GetUserStoreForApplication();
// Specify the file path and options.
using (var isoFileStream = new IsolatedStorageFileStream("/Discount%20it;component/Tax.txt", FileMode.OpenOrCreate, myStore))
{
//Write the data
using (var isoFileWriter = new StreamWriter(isoFileStream))
{
isoFileWriter.WriteLine(textBox1.Text);
}
}
string fileName = "/Discount%20it;component/Tax.txt";
using (var isoStorage = IsolatedStorageFile.GetUserStoreForApplication())
{
// we need to check to see if the file exists
if (!isoStorage.FileExists(fileName))
{
// file doesn't exist...time to create it.
isoStorage.CreateFile(fileName);
}
// since we are appending to the file, we must use FileMode.Append
using (var isoStream = new IsolatedStorageFileStream(fileName, FileMode.Append, isoStorage))
{
// opens the file and writes to it.
using (var fileStream = new StreamWriter(isoStream))
{
fileStream.Write(textBox1.Text);
}
}
}
사용 코드에서 "작동하지 않음"을 보여주십시오 - 충돌했거나 오류가 발생했거나 자동으로 실패 했습니까? – Jason
@ Jason 때로는 Premmision, IsolatedStorage 예외, StreamWriter 예외가 없다고 말했습니다 ... – Yehonatan
두 번째로 코드의 형식을 올바르게 지정하십시오. 답변을 얻는 데 도움이됩니다. – Will