Problems with IsolatedStorage read/write

Discussion in 'ASP .Net' started by Diana L, May 2, 2005.

  1. Diana L

    Diana L Guest

    Hi:

    I'm trying to get this isolated storage snippet to work. It's trying to
    write a few lines, then trying to read them and print them out to the
    browser.

    The browser prints the "Writing..." lines, and the "End of job" line, but no
    "Reading" lines.

    I've tried to debug it a bit, and the reader.Peek() value is -1 prior to the
    first reader.ReadLine() attempt.

    Anyone have any ideas? I'm on VS 2003 & .Net 1.1

    Here's the code:

    private void Page_Load(object sender, System.EventArgs e)

    {

    IsolatedStorageFileStream stream = new IsolatedStorageFileStream

    ("colors.txt",FileMode.Create,FileAccess.ReadWrite);

    StreamWriter writer = new StreamWriter(stream);

    string[] data = { "red", "orange", "yellow", "green", "blue", "indigo" };

    for (int i=0; i<data.Length; i++)

    {

    writer.WriteLine(data);

    Response.Write("Writing: " + data + "<br>");

    }

    stream.Seek(0,SeekOrigin.Begin);

    StreamReader reader = new StreamReader(stream);

    while (reader.Peek() > -1)

    {

    Response.Write("Reading: " + reader.ReadLine() + "<br/>");

    }

    reader.Close();

    Response.Write("Normal eoj.");

    }
     
    Diana L, May 2, 2005
    #1
    1. Advertising

  2. Diana L

    Scott Allen Guest

    Hi Diana:

    You'll want to make sure you close the writer stream before you start
    trying to read - that should help.

    Also - are you sure you want to use isolated storage on the sever?
    It's generally more useful on the client side.

    HTH,

    --
    Scott
    http://www.OdeToCode.com/blogs/scott/

    On Mon, 02 May 2005 04:11:59 GMT, "Diana L" <>
    wrote:

    >Hi:
    >
    >I'm trying to get this isolated storage snippet to work. It's trying to
    >write a few lines, then trying to read them and print them out to the
    >browser.
    >
    >The browser prints the "Writing..." lines, and the "End of job" line, but no
    >"Reading" lines.
    >
    >I've tried to debug it a bit, and the reader.Peek() value is -1 prior to the
    >first reader.ReadLine() attempt.
    >
    >Anyone have any ideas? I'm on VS 2003 & .Net 1.1
    >
    >Here's the code:
    >
    >private void Page_Load(object sender, System.EventArgs e)
    >
    >{
    >
    >IsolatedStorageFileStream stream = new IsolatedStorageFileStream
    >
    >("colors.txt",FileMode.Create,FileAccess.ReadWrite);
    >
    >StreamWriter writer = new StreamWriter(stream);
    >
    >string[] data = { "red", "orange", "yellow", "green", "blue", "indigo" };
    >
    >for (int i=0; i<data.Length; i++)
    >
    >{
    >
    >writer.WriteLine(data);
    >
    >Response.Write("Writing: " + data + "<br>");
    >
    >}
    >
    >stream.Seek(0,SeekOrigin.Begin);
    >
    >StreamReader reader = new StreamReader(stream);
    >
    >while (reader.Peek() > -1)
    >
    >{
    >
    >Response.Write("Reading: " + reader.ReadLine() + "<br/>");
    >
    >}
    >
    >reader.Close();
    >
    >Response.Write("Normal eoj.");
    >
    >}
    >
     
    Scott Allen, May 2, 2005
    #2
    1. Advertising

  3. Diana L

    Diana L Guest

    "Scott Allen" <> wrote

    > You'll want to make sure you close the writer stream before you start
    > trying to read - that should help.


    Thanks, I closed the writer stream (which also closes the
    IsolatedStorageStream), made a new instance of the isolated storage stream,
    and it worked fine.

    -- Diana
     
    Diana L, May 2, 2005
    #3
  4. Diana L

    ravie

    Joined:
    Aug 4, 2006
    Messages:
    1
    How to display it in HTML browser?

    Hello colleagues,
    any action is simple, if you know how to do it...so I have a question, if I get some string (i.e. from IsolatedStorage), let's say it's a HTML code, I would love to know how to open that code (which is in IsolatedStorage present i.e. like a file named XX.html) directly in a web browser window?
    Thank you a lot!
    Ravie.
     
    ravie, Aug 4, 2006
    #4
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Zdenek Drlik
    Replies:
    0
    Views:
    432
    Zdenek Drlik
    Jan 25, 2005
  2. =?Utf-8?B?U2ltb24gQ2hlc3Rlcg==?=

    Problems with Windows 2003 Service Pack 1 and IsolatedStorage

    =?Utf-8?B?U2ltb24gQ2hlc3Rlcg==?=, Jun 22, 2005, in forum: ASP .Net
    Replies:
    0
    Views:
    604
    =?Utf-8?B?U2ltb24gQ2hlc3Rlcg==?=
    Jun 22, 2005
  3. Zdenek Drlik

    IsolatedStorage with impersonation in ASP.NET problem

    Zdenek Drlik, Jan 25, 2005, in forum: ASP .Net Security
    Replies:
    0
    Views:
    138
    Zdenek Drlik
    Jan 25, 2005
  4. Simon Chester
    Replies:
    1
    Views:
    136
    Bob Barrows [MVP]
    Jun 22, 2005
  5. sahm
    Replies:
    4
    Views:
    723
Loading...

Share This Page