954,514 Members — Technology Publication meets Social Media
Username:
Password:
Lost login information?
Have something to say? Contribute New Article Reply to this Article

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

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:

System.Web.UI.WebControls.FileUpload inputFile;
            inputFile = ((System.Web.UI.WebControls.FileUpload)Evidence_GridView.Rows[0].Cells[5].FindControl("Evidence_FileUpload"));

            if ((!(inputFile.PostedFile == null) && (inputFile.PostedFile.ContentLength > 0)))
            {
                string fileName = case_id + " " + IncroControl.getIncro() + " " + System.IO.Path.GetFileName(inputFile.PostedFile.FileName);
                string saveLocation = (this.Page.Server.MapPath(".\\Data\\Evidence") + ("\\" + fileName));
                try
                {
                    // Save the file.
                    inputFile.PostedFile.SaveAs(saveLocation);
                    CMDObj.Parameters.Add("@Attached_File", SqlDbType.NVarChar).Value = fileName;
                }
                catch (Exception ex)
                {
                    this.Page.Response.Write(("Error: " + ex.Message));
                }
            }
            else
            {
                CMDObj.Parameters.Add("@Attached_File", SqlDbType.NVarChar).Value = "";
            }


best regards,

IT_Techno
Light Poster
41 posts since Dec 2007
Reputation Points: 10
Solved Threads: 0
 

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..

LizR
Posting Virtuoso
1,791 posts since Aug 2008
Reputation Points: 196
Solved Threads: 190
 

This article has been dead for over three months

Post: Markdown Syntax: Formatting Help
You