Hi friends,
I have developed a web application in visual studio 2008
its in asp.net c#.
i have user a html page and one txt file in that application
but both are not inside my application
bot are outside
so when i try to run the same application in another system i will get error because of that files.
i want to include that files inside that application.
below is the code lines which i used to write and read that files
//file write test.txt FileStream file1 = new FileStream("test.txt", FileMode.Create, FileAccess.Write);
// Create a new stream to write to the file
StreamWriter sw1 = new StreamWriter(file1);
// Write a string to the file
sw1.Write(emailId);
// Close StreamWriter
sw1.Close();
// Close file
file1.Close();
// * Write to file *
// Specify file, instructions, and privelegdes
FileStream file = new FileStream("test.html", FileMode.Create, FileAccess.Write);
// Create a new stream to write to the file
StreamWriter sw = new StreamWriter(file);
// Write a string to the file
sw.Write(BodyLiteral.Text);
// Close StreamWriter
sw.Close();
// Close file
file.Close();
// * Read from file *
// Specify file, instructions, and privelegdes
file = new FileStream("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 cval = sr.ReadToEnd();
Response.Write(cval);
// Close StreamReader
sr.Close();
// Close file
file.Close();
//html file reading
string text = File.ReadAllText(@"D:\Program Files\Microsoft Visual Studio 9.0\Common7\IDE\test.html");
actually now my both file is in
D:\Program Files\Microsoft Visual Studio 9.0\Common7\IDE\
i want replace all these codes to file inside my web application.
please help me to solve this.
Thanks