How can I open any file, specified by a path, in ASP.NET programatically?
I tried the snippet below but it reads the contents of the file instead of opening the file:
string fileName = @"C:\deneme.txt";
StreamReader sr = File.OpenText(fileName);
while (sr.Peek() != -1)
{
Response.Write(sr.ReadLine() + "<br>");
}
sr.Close();
I also tried the File.Open method.
You can
Response.Redirectto file if you’re just opeining itor if file is being downloaded you can use the folling code;