Guest User

Untitled

a guest
Jun 22nd, 2018
98
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.97 KB | None | 0 0
  1. // Запись
  2.  
  3. IsolatedStorageFile storage = IsolatedStorageFile.GetUserStoreForApplication();
  4. string text = "";
  5. IsolatedStorageFileStream fs = new IsolatedStorageFileStream("text.txt", FileMode.OpenOrCreate, storage);
  6. // Создаем файл (либо открываем уже имеющийся)
  7. StreamWriter  sw = new StreamWriter(fs);
  8.  
  9.  // Записываем текст в файл
  10. sw.Write(text);
  11. sw.Flush();
  12.  
  13. // Закрываем
  14.  sw.Close();
  15.  
  16.  
  17. // Чтение
  18. IsolatedStorageFile storage = IsolatedStorageFile.GetUserStoreForApplication();
  19.  
  20. try
  21. {
  22.      // Создаем поток для чтения данных
  23.      IsolatedStorageFileStream fs = new IsolatedStorageFileStream("Text\\text.txt", FileMode.Open, storage);
  24.      StreamReader sr = new StreamReader(fs);
  25.      // Читаем текст до конца файла
  26.     string text = sr.ReadToEnd();
  27.      
  28.     // Закрываем поток
  29.     sr.Close();
  30. } catch (Exception e) {}
Add Comment
Please, Sign In to add comment