Hi,
I am Opening a simple txt file in Asp.net.It is opening the file but at the end of the file
It is adding all the source code of my page.
Here's the code
TextBox1.Text = CommonFunction.ToString(Session["FilePath"]);
string lfilepath = TextBox1.Text;
string pat = @"\\(?:.+)\\(.+)\.(.+)";
Regex r = new Regex(pat);
//run
Match m = r.Match(lfilepath);
string lfile_ext = m.Groups[2].Captures[0].ToString();
string lfilename = m.Groups[1].Captures[0].ToString();
string lfile = lfilename + "." + lfile_ext;
//string path = Server.MapPath((".\\UploadedFile\\1\\ABCDSummary.txt"));
string path = CommonFunction.ToString(Session["FilePath"]);
FileStream fs = new FileStream(path, FileMode.Open);
//fs = File.Open(path, FileMode.Open);
byte[] bytBytes = new byte[fs.Length + 1];
fs.Read(bytBytes, 0, (int)fs.Length);
fs.Close();
Response.AddHeader("Content-Disposition", "attachment; filename=" + lfile);
Response.ContentType = "APPLICATION/OCTET-STREAM";
Response.Flush();
Response.BinaryWrite(bytBytes);