Thanks Grant,
I have no problem in reading the text file, but displaying at the
appropriate place. I read the document using filestream classes.
If I use Response.Write to display the HTML Contents, it prints the contents
on the TOP or BOTTOM of the ASPX page. Whereas, I want to display the
content at a particular place. Because I have many controls placed as header
and footer. Somehow, I solved the problem by using Label and LiteralControl.
Still the content does not look fine. I'm looking for an alternate...
Thanks for your help.
Ok, here goes
I set the security on c:\test to allow everyone full control.
This is not neccesary, just your ASPNET accounts needs these privileges, or
you can impersonate a user on the server with sufficient privileges
CODE:
using System.IO;
// Specify file, instructions, and privelegdes
FileStream file = new FileStream("c:\\test\\test.txt",
FileMode.OpenOrCreate, FileAccess.Write);
// Create a new stream to write to the file
StreamWriter sw = new StreamWriter(file);
// Write a string to the file
sw.Write("Hello file system world!");
// Close StreamWriter
sw.Close();
// Close file
file.Close();
// *** Read from file ***
// Specify file, instructions, and privelegdes
file = new FileStream("c:\\test\\test.txt", FileMode.OpenOrCreate,
FileAccess.Read);
// Create a new stream to read from a file
StreamReader sr = new StreamReader(file);
// Read contents of file into a string
string s = sr.ReadToEnd();
Response.Write(s);
// Close StreamReader
sr.Close();
// Close file
file.Close();