How to make a file to be downloaded ..?

Posted on 2009-02-21
Last Modified: 2013-11-07
Need to do the show the file from db ,

 i have the file in the folder  and that filename inthe table ,

 how can i show that file to be downloadable .
this below CODE brings the FILENAME ...

but "couldnt" able to show the file ,

so that the user can download ....
plz suggest..?

Public Sub Calendar1_SelectionChanged(ByVal sender As Object, ByVal e As EventArgs)

        con = New SqlConnection(ConfigurationSettings.AppSettings("str1"))

      cmd= New SqlCommand("Single_Date", con)

        cmd.CommandType = CommandType.StoredProcedure

        Dim parameter_Date As New SqlParameter("@_Date", SqlDbType.DateTime, 8)

        parameter_Date.Value = Calendar1.SelectedDate



        myDataReader = myCommand.ExecuteReader()

        Dim temp As String = ""

        'Dim Category As String

        Dim diffdbdate As DateTime

        While (myDataReader.Read())

            diffdbdate = myDataReader.Item("startdate")

            If (myDataReader.Item("freeregreq") = 1 And myDataReader.Item("escrow") = 1) Then

                temp &= "<br>name  :" & myDataReader.Item("cname") & "<br>Filedownload: " & myDataReader.Item("files") & ""

            End If

        End While

        Label1.Text = temp



    End Sub

Open in new window

Question by:Rajar Ahmed
    LVL 9

    Assisted Solution

    by:Ken Fayal
    You should put the file name in <A HREF> tags so that it will show as a link, but you have to provide the full path to the file.
    LVL 18

    Author Comment

    by:Rajar Ahmed
    I dint see the file name  and there is a link field which shows url f:/projext/filesfilename.txt on the status bar..
    temp &= "<br>name  :" & myDataReader.Item("cname") & "<br>Filedownload: <a href=""F:\projext\files" & myDataReader.Item("files") & """>"

    LVL 18

    Author Comment

    by:Rajar Ahmed
    temp &= "<br>name  :" & myDataReader.Item("cname") & "<br>Filedownload: <a href=""http://F:/projext/files/t"">" & myDataReader.Item("files") & "</a>"

    this is transfering the page to this url and loading the cannot open page rather than downloading the file
    LVL 12

    Accepted Solution

    meeran03, do you have the folder as a virtual path? if so, then the http address with the location is sufficient.  You just need to append the file name from the db to the virtual path and assign it to the href of the hyperlink as
         temp &= "<br>name  :" & myDataReader.Item("cname") & "<br>Filedownload: <a href='http://projext/files/t/" & myDataReader.Item("files") & "'>" & myDataReader.Item("files") & "</a>"
    assuming http://projext/files/t/ as your virtual path.

    But, if you have the file in a shared location or in the file system, that do not have the virtual path then refer
    LVL 18

    Author Closing Comment

    by:Rajar Ahmed
    thanks .. i created the virtual path and did...

    Featured Post

    Better Security Awareness With Threat Intelligence

    See how one of the leading financial services organizations uses Recorded Future as part of a holistic threat intelligence program to promote security awareness and proactively and efficiently identify threats.

    Join & Write a Comment

    Introduction This article shows how to use the open source plupload control to upload multiple images. The images are resized on the client side before uploading and the upload is done in chunks. Background I had to provide a way for user…
    Parsing a CSV file is a task that we are confronted with regularly, and although there are a vast number of means to do this, as a newbie, the field can be confusing and the tools can seem complex. A simple solution to parsing a customized CSV fi…
    Hi everyone! This is Experts Exchange customer support.  This quick video will show you how to change your primary email address.  If you have any questions, then please Write a Comment below!
    Excel styles will make formatting consistent and let you apply and change formatting faster. In this tutorial, you'll learn how to use Excel's built-in styles, how to modify styles, and how to create your own. You'll also learn how to use your custo…

    729 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    15 Experts available now in Live!

    Get 1:1 Help Now