My app needs to provide download of files (in this case .doc files) that
exist on the file system. I have the physical filestring i.e.
c:\myfilesdir\smith resume.doc.
but if I load that into a navigateurl it doesn't work. Nor does
file://c:\myfilesdir\smith resume.doc. Or any thing else I try.
How can I do this?
Thanks,
T
nahid - 14 Aug 2007 05:50 GMT
> My app needs to provide download of files (in this case .doc files) that
> exist on the file system. I have the physical filestring i.e.
[quoted text clipped - 6 lines]
> Thanks,
> T
hi,
try this way
String file = Server.MapPath("~/labla/") +
"labla....";
string fileName = "ClientFileName";
try
{
FileStream downloadFile = new FileStream(file,
FileMode.Open);
Response.Clear();
Response.ContentType = "application/octet-stream";
Response.AddHeader("Content-Disposition",
"attachment; filename=\"" + fileName + "\"");
Response.AddHeader("Content-Length",
downloadFile.Length.ToString());
downloadFile.Close();
Response.WriteFile(file);
Response.Flush();
}
catch (Exception ex)
{
//...............
}
hope help
nahid
http://nahidulkibria.blogspot.com
Steve C. Orr [MCSD, MVP, CSM, ASP Insider] - 14 Aug 2007 12:57 GMT
You should be able to distribute your files as desired using the techniques
I've detailed here:
http://dotnetslackers.com/articles/aspnet/FileDenial.aspx

Signature
I hope this helps,
Steve C. Orr,
MCSD, MVP, CSM, ASPInsider
http://SteveOrr.net
> My app needs to provide download of files (in this case .doc files) that
> exist on the file system. I have the physical filestring i.e.
[quoted text clipped - 6 lines]
> Thanks,
> T
Steve C. Orr [MCSD, MVP, CSM, ASP Insider] - 14 Aug 2007 12:58 GMT
You should be able to distribute your files as desired using the techniques
I've detailed here:
http://dotnetslackers.com/articles/aspnet/FileDenial.aspx

Signature
I hope this helps,
Steve C. Orr,
MCSD, MVP, CSM, ASPInsider
http://SteveOrr.net
> My app needs to provide download of files (in this case .doc files) that
> exist on the file system. I have the physical filestring i.e.
[quoted text clipped - 6 lines]
> Thanks,
> T