ftp上传
Protected Sub Button1_ServerClick(ByVal sender As Object, ByVal e As System.EventArgs) Handles Button1.ServerClick
Dim fileInf As New System.IO.FileInfo("c:\1234.jpg")
Const host As String = "ftp://www.wye.cn"
Const username As String = "keke"
Const password As String = "3537"
Dim uri As String = host + "/" + fileInf.Name.ToString
Dim ftp As System.Net.FtpWebRequest = CType(System.Net.FtpWebRequest.Create(uri), System.Net.FtpWebRequest)
ftp.Credentials = New System.Net.NetworkCredential(username, password)
ftp.KeepAlive = False
ftp.UseBinary = True
ftp.Method = System.Net.WebRequestMethods.Ftp.UploadFile
Dim response0 As System.Net.FtpWebResponse = CType(ftp.GetResponse, System.Net.FtpWebResponse)
Dim responsestream As System.IO.Stream = ftp.GetRequestStream
Dim fs As IO.FileStream
fs = fileInf.OpenRead
Dim buffer(2048) As Byte
Dim read As Integer = 0
Do
read = fs.Read(buffer, 0, buffer.Length)
responsestream.Write(buffer, 0, read)
Loop Until read = 0
responsestream.Close()
fs.Flush()
fs.Close()
response0.Close()
Response.Write("sssssssssssssssssssssssssssssssssssssssssssssc")
End Sub
这个是有问题的,就是上传的文件路径应该用上传文件控件得到,不然话就是服务器上这个文件
本文使用Blog_Backup未注册版本导出,请到soft.pt42.com注册。