File Copy Problem

lothos12345

Junior Contributor
Joined
May 2, 2002
Messages
294
Location
Texas
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.
 
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
 
Back
Top