关于vb.net实现文件上传的信息
跪求在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 pHnd 0 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如何上传文件
My.Computer.Network.UploadFile
比如上传到FTP
My.Computer.Network.UploadFile("d:\1.txt", "“, "FTP账号", "FTP密码", True, 100)
新手路过。
vb.net ftp上传文件
Dim OpenFileDialog As New OpenFileDialog
OpenFileDialog.InitialDirectory = My.Computer.FileSystem.SpecialDirectories.MyDocuments
OpenFileDialog.Filter = "文本文件(*.jpg)|*.jpg|所有文件(*.*)|*.*"
If (OpenFileDialog.ShowDialog(Me) = System.Windows.Forms.DialogResult.OK) Then
Dim FileName As String = OpenFileDialog.FileName
' TODO: 在此处添加打开文件的代码。
textbox1.Text = FileName
End If
第一个按钮 上传
Dim filelast As String = fileaddbefore.Text.Substring(fileaddbefore.Text.LastIndexOf("."), fileaddbefore.Text.Length - fileaddbefore.Text.LastIndexOf("."))
MessageBox.Show(filelast)
My.Computer.Network.UploadFile(textbox1.Text, "" 文件名.Text filelast, "登录名1", "登录密码", True, 100)
第二个按钮
VB中如何实现上传文件的功能?
用script脚本 直接调用 FTP 命令实现上传文件到FTP服务器。
代码如下:
'定义API函数
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() '取时间为文件名filename
Open filename ".script" For Output As #1 '生成filename.script脚本,传输FTP用
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 '生成的filename.txt保存了combo1和text1的文字
Print #1, Text1.Text
Print #1, Combo1.Text
Close #1
DoEvents
'调用ftp命令传输,不需要inet或winsock控件
Dim pId As Long, pHnd As Long
pId = Shell("ftp -n -s:" filename ".script" " " ftp, vbHide)
pHnd = OpenProcess(SYNCHRONIZE, 0, pId)
If pHnd 0 Then
Call WaitForSingleObject(pHnd, INFINITE)
Call CloseHandle(pHnd)
End If
Kill filename ".script" '因为script脚本保存了帐号和密码,当传输完成后删除filename.script脚本
End Sub
VB.net 读取文本文件?
1、实现上传按钮方法代码。
2、判断图片对象是否为空代码。
3、取得数据库字段 dt.Rows(0)("Pic")方法代码。
4、字节数组转换为Image类型方法代码。
5、处理SQL中操作Image类型方法代码。
6、实现的上传结果。
新闻标题:关于vb.net实现文件上传的信息
文章URL:http://azwzsj.com/article/docjiej.html