I want to save text from a textbox to the internalStorage and load it from there…
The saving-part works fine. But the loading won’t work I tried many tutorials already.
private void button2_Click(object sender, RoutedEventArgs e)
{
//get selected FileName from listBox
string selItem = listBox1.SelectedItem.ToString();
IsolatedStorageFile myStore = IsolatedStorageFile.GetUserStoreForApplication();
if (selItem != null)
{
IsolatedStorageFileStream fileStream = store.OpenFile(selItem, FileMode.Open, FileAccess.Read);
using (StreamReader sr = new StreamReader(fileStream))
{
String line = "";
//Debug.WriteLine("ReadLine");
if ((line = sr.ReadLine()) != null)
{
//Debug.WriteLine("ReadLineText");
textBox1.Text = line;
}
sr.Close();
}
fileStream.Close();
}
}
Instead of:
if ((line = sr.ReadLine()) != null)
{
//Debug.WriteLine("ReadLineText");
textBox1.Text = line;
I’ve tried many possibilities like: textBox1.Text = sr.ReadLine(); and so on..
The curious thing about he code is: If I enter for example:
IsolatedStorageFileStream fileStream = store.OpenFile("text0.txt", FileMode.Open, FileAccess.Read);
It works fine for the single file text0.txt.
Would be really really great if someone give me some tips to fix the code.
Thanks in advance..
this is how I open an ISF Stream