Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / ASP.NET / General / August 2007

Tip: Looking for answers? Try searching our database.

downloading files from filesystem

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Tina - 14 Aug 2007 02:15 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.
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

Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.