如何下载图像 [英] How to Download the image

查看:87
本文介绍了如何下载图像的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我上传图像数据库Ms访问和文件夹

但我不知道如何下载图像



 尝试 
如果(con.State = ConnectionState.Closed)< span class =code-keyword>然后
con.Open()
结束 如果
Dim curdir As 字符串 = AppDomain.CurrentDomain.SetupInformation.ApplicationBase
如果 ID<> 0 然后
如果 txtFileUploadPath.Text = 没什么 < span class =code-keyword>不 字符串 .IsNullOrEmpty(txtFileUploadPath.Text))然后
FileIO.FileSystem.DeleteFile(curdir& Excel \&主题)
' 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)
其他
objdal.ExamSchedule =
结束 如果
objdal.ID = ID
objdal.UpdateExamSchedule()
否则
Dim doc 作为 字符串()
Dim ext As String
doc = txtFileUploadPath.Text。拆分( 字符(),( ))
ext = doc(doc.Length - 1

如果 txtFileUploadPath.Text = 没有 字符串 .IsNullOrEmpty(txtFileUploadPath.Text))然后
' objdal.ExamSchedule = CmboSubject.Text& _& CmboSub_Subject.Text& &安培; ext
objdal.ExamSchedule = TxtSubject.Text& & ext
FileCopy(txtFileUploadPath.Text,curdir& Excel \& objdal .ExamSchedule)
其他
objdal.ExamSchedule =
结束 如果
Dim cmd 作为 OleDbCommand( 插入FileUpload(Sid,Sub_ID,CID,Sub_Cid,Subject,FileUpload)值(& CmboSubject.SelectedValue& amp; ; & 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()
结束 如果
Catch ex As Exception
MessageBox.Show(ex.ToString())
结束 尝试





请他使用WebClient对象的DownloadFile方法:



http://msdn.microsoft.com/en-us/library/ez801hhe.aspx [ ^ ]


i upload the Image in Database Ms access and Folder
But I don't Know How to Download the Image

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

解决方案

Use the WebClient object's DownloadFile method:

http://msdn.microsoft.com/en-us/library/ez801hhe.aspx[^]


这篇关于如何下载图像的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆