|
|
|
start date: Mon, 13 Aug 2007 18:15:10 -0700,
posted on: microsoft.public.dotnet.framework.aspnet
back
| Thread Index |
|
1
Tina
|
|
2
nahid
|
|
3
Steve C. Orr [MCSD, MVP, CSM, ASP Insider]
|
|
4
Steve C. Orr [MCSD, MVP, CSM, ASP Insider]
|
downloading files from filesystem
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
Date:Mon, 13 Aug 2007 18:15:10 -0700
Author:
|
Re: downloading files from filesystem
On Aug 14, 7:15 am, "Tina" wrote:
> 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
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
Date:Mon, 13 Aug 2007 21:50:08 -0700
Author:
|
Re: downloading files from filesystem
You should be able to distribute your files as desired using the techniques
I've detailed here:
http://dotnetslackers.com/articles/aspnet/FileDenial.aspx
--
I hope this helps,
Steve C. Orr,
MCSD, MVP, CSM, ASPInsider
http://SteveOrr.net
"Tina" wrote in message
news:uxBzQCh3HHA.1204@TK2MSFTNGP03.phx.gbl...
> 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
>
Date:Tue, 14 Aug 2007 04:57:04 -0700
Author:
|
Re: downloading files from filesystem
You should be able to distribute your files as desired using the techniques
I've detailed here:
http://dotnetslackers.com/articles/aspnet/FileDenial.aspx
--
I hope this helps,
Steve C. Orr,
MCSD, MVP, CSM, ASPInsider
http://SteveOrr.net
"Tina" wrote in message
news:uxBzQCh3HHA.1204@TK2MSFTNGP03.phx.gbl...
> 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
>
Date:Tue, 14 Aug 2007 04:58:03 -0700
Author:
|
|
|