Jump to content
Xtreme .Net Talk

Recommended Posts

Posted
I wrote a program in asp.net VB. I want a user to be able to download a selected file from the application to there local harddrive. However, when a user clicks the download button it downloads the file onto the server, The computer that is actually hosting this page. How can I fix this problem. Any help given is greatly appreciated.
Posted

Yes

 

Here is the code. Thanks for the help:

 

Private Sub btndwnitm_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btndwnitm.Click

Dim strconn As String = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=\\emis03\c\webdatabases\cdlib.mdb"

Dim objdbconn As New OleDb.OleDbConnection(strconn)

objdbconn.Open()

 

Try

TextBox5.Text = Environment.UserDomainName

Dim clsname As String

Dim flesource As String

Dim drcodesnips As OleDb.OleDbDataReader

Dim cmdsnip As New OleDb.OleDbCommand("SELECT Filename, location FROM codelib WHERE FileName = '" & DropDownList2.SelectedValue.ToString & "'", objdbconn)

cmdsnip.CommandType = CommandType.Text

drcodesnips = cmdsnip.ExecuteReader

While drcodesnips.Read

flesource = drcodesnips.Item("location")

clsname = drcodesnips.Item("FileName")

End While

objdbconn.Close()

 

If Directory.Exists("\\" & Environment.UserDomainName & "\c\clsdownloads\") = False Then

Directory.CreateDirectory("\\" & Environment.UserDomainName & "\c\clsdownloads\")

End If

File.Copy(flesource, "\\" & Environment.UserDomainName & "\c\clsdownloads\" & clsname, True)

Catch ex As Exception

objdbconn.Close()

End Try

End Sub

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...