Problems with IsolatedStorage read/write

D

Diana L

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.");

}
 
S

Scott Allen

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,
 
D

Diana L

Scott Allen said:
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
 
Joined
Aug 4, 2006
Messages
1
Reaction score
0
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.
 

Ask a Question

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

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,755
Messages
2,569,536
Members
45,009
Latest member
GidgetGamb

Latest Threads

Top