How to open or download files iasp.net using c#

Please support our C# advertiser: Intel Parallel Studio Home
Reply

Join Date: Dec 2007
Posts: 41
Reputation: IT_Techno is an unknown quantity at this point 
Solved Threads: 0
IT_Techno IT_Techno is offline Offline
Light Poster

How to open or download files iasp.net using c#

 
0
  #1
Nov 6th, 2008
hi

i have created application that uploaded files (.zip, .doc, ... any type ) to file system and then i have create another code to download the files but i need so have the option to open also the file if i do not need to save it on my computer can any one helpe me to do that
this some code how i download:

  1. System.Web.UI.WebControls.FileUpload inputFile;
  2. inputFile = ((System.Web.UI.WebControls.FileUpload)Evidence_GridView.Rows[0].Cells[5].FindControl("Evidence_FileUpload"));
  3.  
  4. if ((!(inputFile.PostedFile == null) && (inputFile.PostedFile.ContentLength > 0)))
  5. {
  6. string fileName = case_id + " " + IncroControl.getIncro() + " " + System.IO.Path.GetFileName(inputFile.PostedFile.FileName);
  7. string saveLocation = (this.Page.Server.MapPath(".\\Data\\Evidence") + ("\\" + fileName));
  8. try
  9. {
  10. // Save the file.
  11. inputFile.PostedFile.SaveAs(saveLocation);
  12. CMDObj.Parameters.Add("@Attached_File", SqlDbType.NVarChar).Value = fileName;
  13. }
  14. catch (Exception ex)
  15. {
  16. this.Page.Response.Write(("Error: " + ex.Message));
  17. }
  18. }
  19. else
  20. {
  21. CMDObj.Parameters.Add("@Attached_File", SqlDbType.NVarChar).Value = "";
  22. }

best regards,
Last edited by cscgal; Nov 6th, 2008 at 12:15 pm. Reason: Added code tags
Reply With Quote Quick reply to this message  
Join Date: Aug 2008
Posts: 1,735
Reputation: LizR has a spectacular aura about LizR has a spectacular aura about 
Solved Threads: 186
LizR LizR is offline Offline
Posting Virtuoso

Re: How to open or download files iasp.net using c#

 
0
  #2
Nov 6th, 2008
Depending on the file, if you're downloading something to display specifically such as text, sure, otherwise if you need to pass it to an app such as zip files, word docs etc, you cant, the best you can do is temp files..
Did I just hear "You gotta help us, Doc. We've tried nothin' and we're all out of ideas" ? Is this you? Dont let this be you! I will put in as much effort as you seem to.
Reply With Quote Quick reply to this message  
Reply

This thread is more than three months old.
Perhaps start a new thread instead?
Message:


Thread Tools Search this Thread



About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC