如何将文件中的大量图像发送到ftp服务器?
问题描述:
Imports System.Net.FtpWebRequest
Imports System.Net.NetworkInformation
Public Class Form1
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Try
'server path
Dim clsRequest As System.Net.FtpWebRequest =_
DirectCast(System.Net.WebRequest.Create("E:\Image.jpeg"), System.Net.FtpWebRequest)
clsRequest.Credentials = New System.Net.NetworkCredential("USERNAME", "PASSWORD")
clsRequest.Method = System.Net.WebRequestMethods.Ftp.UploadFile
' read in file...
'local path
Dim bFile() As Byte = System.IO.File.ReadAllBytes("C:\Image.jpg")
' upload file...
Dim clsStream As System.IO.Stream = _
clsRequest.GetRequestStream()
clsStream.Write(bFile, 0, bFile.Length)
clsStream.Close()
clsStream.Dispose()
MsgBox("OVER.......!!!!!")
Me.Close()
Catch ex As Exception
MsgBox(ex.Message, MsgBoxStyle.OkCancel)
If MsgBoxResult.Cancel Then
Me.Close()
End If
End Try
End Sub
此代码正确运行,但只有一个图像发送到ftp服务器
我有一个文件我有很多图像我想将所有图像发送到ftp服务器
我该怎么办?
标记已更改-LOSMAC [/EDIT]
this code true thıs ıs run but only one image send to ftp server
ı have a fıle ıt has lots of image ı want to send all of them to ftp server
how can ı do?
Tags changed - LOSMAC[/EDIT]
答
FTP服务器没有顶部或底部;一个人会说它是无底的(即使没有顶部",但也不会无顶):-)
FTP服务器没有用于上传多个文件的命令.这样的操作必须是一组操作,每个操作都上传一个文件,就是这样.—SA
An FTP server does not have a top or bottom; one would say it''s bottomless (but not topless, even though there is no a "top") :-)
An FTP server does not have a command for uploading of more than one file; such operation has to be a set of operations each uploading a single file, that''s it.—SA