I have solved this issue in another way.After writing the content into text file.I wrote the content of ReleaseNote.txt into the TextFile.aspx page again.This is something as follows within page load event of that page.
protected void Page_Load(object sender, EventArgs e)
{
string filename = "ReleaseNote.txt";
try
{
if (!Page.IsPostBack)
{
Response.ContentType = "application/octet-stream";
Response.AddHeader("content-disposition", "attachment; filename=" + filename);
FileStream sourceFile = new FileStream(Server.MapPath("~/ReleaseNotes/" + filename), FileMode.Open, FileAccess.Read, FileShare.ReadWrite);
long FileSize;
FileSize = sourceFile.Length;
if (sourceFile.Length > 0)
{
byte[] getContent = new byte[(int)FileSize];
sourceFile.Read(getContent, 0, (int)sourceFile.Length);
sourceFile.Close();
Response.BinaryWrite(getContent);
}
else
{
Response.Write("File is Empty");
}
Response.End();
}
}
catch (Exception ex)
{
Response.End();
}
}
I opened that TextFile.aspx page from code behind of some other page by writing the code something like this:
ClientScript.RegisterStartupScript(typeof(Page), "ErrorOccurred", "<script type='text/javascript'>window.open('ReleaseNotes/TextFile.aspx')</script>");