ASP.Net/File Directory/IsolatedStorageFileStream
StreamWriter from IsolatedStorageFileStream
<source lang="csharp">
<%@ Page %> <script runat="server" language="C#"> void Page_Load(Object sender, EventArgs e) {
System.IO.IsolatedStorage.IsolatedStorageFileStream stream = null; System.IO.StreamReader reader = null; System.IO.StreamWriter writer = null; String data = "The data"; try { stream = new System.IO.IsolatedStorage.IsolatedStorageFileStream("Data.txt", System.IO.FileMode.OpenOrCreate); writer = new System.IO.StreamWriter(stream); writer.WriteLine(data); } catch (Exception ex) { Response.Write(ex.ToString()); } finally { writer.Close(); stream.Close(); } try { stream = new System.IO.IsolatedStorage.IsolatedStorageFileStream("Data.txt", System.IO.FileMode.OpenOrCreate); reader = new System.IO.StreamReader(stream); while ( reader.Peek() > -1 ) { Response.Write(Server.HtmlEncode(reader.ReadLine()) + "
"); } } catch (Exception exc) { Response.Write(exc.ToString()); } finally { stream.Close(); reader.Close(); }
} </script>
</source>
Using IsolatedStorageFileStream
<source lang="csharp">
<%@ Page %> <script language="C#" runat="server"> void Page_Load(Object sender, EventArgs e) {
System.IO.IsolatedStorage.IsolatedStorageFileStream stream = null; System.IO.StreamWriter writer = null; String data = "The data you want to store"; try { stream = new System.IO.IsolatedStorage.IsolatedStorageFileStream("Data.txt", System.IO.FileMode.OpenOrCreate); writer = new System.IO.StreamWriter(stream); writer.WriteLine(data); } catch (Exception ex) { Response.Write(ex.ToString()); } finally { writer.Close(); stream.Close(); }
} </script>
</source>