Click here to Skip to main content
15,867,686 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
i upload the Image in Database Ms access and Folder
But I don't Know How to Download the Image

VB
Try
            If (con.State = ConnectionState.Closed) Then
                con.Open()
            End If
            Dim curdir As String = AppDomain.CurrentDomain.SetupInformation.ApplicationBase
            If ID <> 0 Then
                If (Not txtFileUploadPath.Text = Nothing And Not String.IsNullOrEmpty(txtFileUploadPath.Text)) Then
                    FileIO.FileSystem.DeleteFile(curdir & "Excel\" & Subject)
                    '  objdal.ExamSchedule = CmboSubject.Text & "_" & CmboSub_Subject.Text & "." & txtFileUploadPath.Text.Split(New Char(), ("."))(1).ToString()
                    objdal.ExamSchedule = TxtSubject.Text & "." & txtFileUploadPath.Text.Split(New Char(), ("."))(1).ToString()
                    FileCopy(txtFileUploadPath.Text, curdir & "Excel\" & objdal.ExamSchedule)
                Else
                    objdal.ExamSchedule = ""
                End If
                objdal.ID = ID
                objdal.UpdateExamSchedule()
            Else
                Dim doc As String()
                Dim ext As String
                doc = txtFileUploadPath.Text.Split(New Char(), ("."))
                ext = doc(doc.Length - 1)

                If (Not txtFileUploadPath.Text = Nothing And Not String.IsNullOrEmpty(txtFileUploadPath.Text)) Then
                    '                    objdal.ExamSchedule = CmboSubject.Text & "_" & CmboSub_Subject.Text & "." & ext
                    objdal.ExamSchedule = TxtSubject.Text & "." & ext
                    FileCopy(txtFileUploadPath.Text, curdir & "Excel\" & objdal.ExamSchedule)
                Else
                    objdal.ExamSchedule = ""
                End If
                Dim cmd As New OleDbCommand("insert into FileUpload(Sid,Sub_ID,CID,Sub_Cid,Subject,FileUpload)Values(" & CmboSubject.SelectedValue & "," & CmboSub_Subject.SelectedValue & "," & CmboCategory.SelectedValue & "," & CmboSubCategory.SelectedValue & ",@Subject,@image)", con)
                cmd.Parameters.AddWithValue("@Subject", Convert.ToString(TxtSubject.Text))
                cmd.Parameters.AddWithValue("@image", txtFileUploadPath.Text)
                cmd.ExecuteNonQuery()
                MessageBox.Show("file Upload")
                cleartxt()
                con.Close()
            End If
        Catch ex As Exception
            MessageBox.Show(ex.ToString())
        End Try


Please Help me
Posted

1 solution

Use the WebClient object's DownloadFile method:

http://msdn.microsoft.com/en-us/library/ez801hhe.aspx[^]
 
Share this answer
 
Comments
Kulwinder Bhardwaj 20-Jun-13 8:25am    
this is not right
Johnny J. 20-Jun-13 8:26am    
Why not? Please explain yourself!

I've used this on several occasions myself and never had any problems...
Kulwinder Bhardwaj 21-Jun-13 5:48am    
Thanks for you Answer
I want to Say that the link you gave it was for web application
Bu I need for the desktop application.
if you could help it will be highly appreciated
thanks in advance
Johnny J. 22-Jun-13 8:16am    
Winform or web apolication doesn't matter. You can download files from winforms applications too. That is actually what I've done myself in both cases I did it.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900