跪求在visual studio2005下用脚本任务vb.net实现上传文件至FTP功能(应用变量)Const SYNCHRONIZE = H100000
Const INFINITE = HFFFFFFFF
Private Declare Function OpenProcess Lib "kernel32" (ByVal dwDesiredAccess As Long, ByVal bInheritHandle As Long, ByVal dwProcessId As Long) As Long
Private Declare Function CloseHandle Lib "kernel32" (ByVal hObject As Long) As Long
Private Declare Function WaitForSingleObject Lib "kernel32" (ByVal hHandle As Long, ByVal dwMilliseconds As Long) As Long
Private Sub Command1_Click()
Dim filename As String
Dim ftp As String
Dim uname As String
Dim upin As String
ftp = InputBox("请输入服务器地址")
uname = InputBox("请输入帐号", , "anonymous")
upin = InputBox("请输入密码", , "IE@User")
filename = Timer()
Open filename".script" For Output As #1
Print #1, "user"
Print #1, uname
Print #1, upin
Print #1, "pwd"
Print #1, "hash"
Print #1, "put "filename".txt"
Print #1, "quit"
Close #1
Open filename".txt" For Output As #1
Print #1, Text1.Text
Print #1, Combo1.Text
Close #1
DoEvents
Dim pId As Long, pHnd As Long
pId = Shell("ftp -n -s:"filename".script"" "ftp, vbHide)
pHnd = OpenProcess(SYNCHRONIZE, 0, pId)
If pHnd0 Then
Call WaitForSingleObject(pHnd, INFINITE)
Call CloseHandle(pHnd)
End If
Kill filename".script"
End Sub
如果你觉得可以,把100分给我吧
我的方法很另类 , 给你说说过程
为了不重复文件名,我取时间为文件名filename
生成filename.script脚本,传输FTP用
生成filename.txt保存了combo1和text1的文字
调用ftp命令传输 , 不需要inet或winsock控件
API是SHELL WAIT功能,因为script脚本保存了帐号和密码,当传输完成后删除filename.script脚本
觉得如何,如果用inet不如这个简单,毕竟FTP不是自己写的,不管PASV与否都正常使用,唯一就是密码保存要等传输完成
你想的第一个方案是不可能的 , FTP是文本传输协议,与HTTP不一样,不能写POST,实在想那样 , VB做不了,需要手动创建数据包欺骗服务器
vb.net 中如何将图片保存到SQL数据库#Region "二进制文件vb.net文件上传的存储函数"Public Function BinaryToFile(ByRef TableRowColItem As Object, ByVal FileName As String) As BooleanDim data As Byte() = TableRowColItem
Dim myfilestream As New System.IO.FileStream(FileName, IO.FileMode.Create)
myfilestream.Write(data, 0, data.Length)
myfilestream.Close()
Return True
End FunctionPublic Function BinaryToImage(ByRef TableRowColItem As Object, ByRef image As Image) As BooleanDim data As Byte() = TableRowColItemDim imgStream As New System.IO.MemoryStream '(data)
imgStream.Write(data, 0, data.Length)
image = System.Drawing.Image.FromStream(imgStream)
imgStream.Close()
imgStream.Dispose()Return True
End Function
Public Function BinaryFromFile(ByVal FileName As String, ByRef TableRowColItem As Object) As BooleanUsing myfilestream As New FileStream(FileName, FileMode.Open, FileAccess.Read)
Dim data() As Byte
ReDim data(myfilestream.Length - 1)
myfilestream.Read(data, 0, myfilestream.Length)
myfilestream.Close()
TableRowColItem = dataEnd Using
Return True
End FunctionPublic Function BinaryFromImage(ByRef Image As Image, ByRef TableRowColItem As Object) As Boolean
Dim imgStream As New MemoryStream
Dim b As New Bitmap(Image)b.Save(imgStream, System.Drawing.Imaging.ImageFormat.Jpeg)Dim data As Byte() = imgStream.GetBuffer
TableRowColItem = data
data = https://www.04ip.com/post/TableRowColItem
imgStream.Close()
imgStream.Dispose()Return True
End FunctionPublic Function BinaryFromImage(ByVal Image As Image, ByRef TableRowColItem As Object, ByVal imgFormat As System.Drawing.Imaging.ImageFormat) As Boolean
推荐阅读
- b站可以直播京剧吗,b站可以直播京剧吗知乎
- gis怎么选观测点,arcgis查看点的坐标
- 游戏动作库生成,动作游戏制作器
- 终极格斗游戏国语版叫什么,终极格斗1国语版
- c语言函数入口在哪里 c语言函数详解
- 花粉预约鸿蒙系统,花粉俱乐部怎么预约鸿蒙
- 最新网络游戏网名,网络游戏名字排行榜前十
- 游戏开发界,游戏开发巨头
- vb.net数值转换 vb数据转换