DaniWeb IT Discussion Community

DaniWeb IT Discussion Community (http://www.daniweb.com/forums/index.php)
-   C# (http://www.daniweb.com/forums/forum61.html)
-   -   How to open or download files iasp.net using c# (http://www.daniweb.com/forums/thread155671.html)

IT_Techno Nov 6th, 2008 9:02 am
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,

LizR Nov 6th, 2008 10:06 am
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..


All times are GMT -4. The time now is 10:48 pm.

Forum system based on vBulletin Copyright ©2000 - 2010, Jelsoft Enterprises Ltd.
©2003 - 2010 DaniWeb® LLC