Hi all,

I would like to open a file in Local drive using Asp.net,

And I have written the following code in user control which could open the file,

Response.AddHeader("Content-Disposition", "attachment; filename=" & strFilename)
Response.WriteFile("C:\\open\\" & strFilename)

The above code working fine in .Net 2005, In SharePoint also I am able to open the file, But After opening the file I am unable to do Any operation in that page, I can do any operation once I refresh the page....

Any Suggestions???

Kindly revert back to me if u have concerns...

Thanks in Advance,


string fileName = @"C:\deneme.txt";
        StreamReader sr = File.OpenText(fileName);
        while (sr.Peek() != -1)
            Response.Write(sr.ReadLine() + "<br>");

you cant do any more writing to the page once you close the response. There is really no reason to close the response anyways.

also, if all you are sending is the file to be saved then use Response.TransmitFile