943,822 Members | Top Members by Rank

Ad:
  • C# Discussion Thread
  • Unsolved
  • Views: 1264
  • C# RSS
Nov 6th, 2008
0

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

Expand Post »
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:

C# Syntax (Toggle Plain Text)
  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
Reputation Points: 10
Solved Threads: 0
Light Poster
IT_Techno is offline Offline
41 posts
since Dec 2007
Nov 6th, 2008
0

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

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..
Reputation Points: 196
Solved Threads: 190
Posting Virtuoso
LizR is offline Offline
1,735 posts
since Aug 2008

This thread is more than three months old

No one has posted to this discussion for at least three months. Please let old threads die and do not reply to them unless you feel you have something new and valuable to contribute that absolutely must be added to make the discussion complete. Otherwise, please start a new thread in this forum instead.
Message:
Previous Thread in C# Forum Timeline: read a text file into a 3D array
Next Thread in C# Forum Timeline: C# Forms: Handling GUI clicks during BackgroundWorker





About Us | Contact Us | Advertise | Acceptable Use Policy
Forum Index | Build Custom RSS Feed


Follow us on Twitter


© 2011 DaniWeb® LLC