0

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)
Response.Flush()
Response.Close()

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,

kumar.

3
Contributors
2
Replies
3
Views
9 Years
Discussion Span
Last Post by plazmo
0
string fileName = @"C:\deneme.txt";
        StreamReader sr = File.OpenText(fileName);
        while (sr.Peek() != -1)
        {
            Response.Write(sr.ReadLine() + "<br>");
        }
        sr.Close();
0

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

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.