用winsock控件 *********************************************************Private Sub cmdSend_Click() '向服务器发送文件 Dim myFile() As Byte Dim lngFile As Long '文件长度 Dim FileName As String '文件名称 Static i As Single
sockClient.Close sockClient.Connect
Do DoEvents If sockClient.State = sckConnected Then Exit Do Else i = i + 1 If i > 200000 Then Dim box As String box = MsgBox("是否放弃?", vbYesNo, "连接失败:") If box = vbYes Then i = 0 Exit Do Else i = 0 End If End If End If DoEvents Loop lenth = 0 '检查是否与服务器连接 If sockClient.State = sckConnected Then FileName = VB.App.Path & "\1.doc" '取得文件名及路径 lngFile = FileLen(FileName) '取得文件长度 ReDim myFile(lngFile - 1) As Byte '初始化数组
Open FileName For Binary As #1 '打开文件 Get #1, , myFile '将文件写入数组 Close #1 '关闭文件 sockClient.SendData myFile '发送 Else MsgBox "没有连接" End If End Sub'******************************************************************Private Sub sockServer_DataArrival(Index As Integer, ByVal bytesTotal As Long) '接收文件 Static i As Long Dim myFile() As Byte Dim myLong As Double Dim myPath As String myPath = VB.App.Path & "\a.doc" cmdC.Caption = "正在接收数据... " & bytesTotal ReDim myFile(0 To bytesTotal - 1) '此处也可以是(0 To bytesTotal-1)
sockServer(Index).GetData myFile i = i + 1
Open myPath For Binary As #1 '新建文件 Put #1, lenth + 1, myFile '将收到的数据写入新文件中 Close #1 '关闭 '记录文件长度 lenth = lenth + UBound(myFile) - LBound(myFile) + 1
End Sub'******************************************************************
to: xayzmb(行者) ( ) 请问接收的计算机是否也要装一个程序呢-_-! 我的意思是程序只在本机运行~
*********************************************************Private Sub cmdSend_Click()
'向服务器发送文件
Dim myFile() As Byte
Dim lngFile As Long '文件长度
Dim FileName As String '文件名称
Static i As Single
sockClient.Close
sockClient.Connect
Do
DoEvents
If sockClient.State = sckConnected Then
Exit Do
Else
i = i + 1
If i > 200000 Then
Dim box As String
box = MsgBox("是否放弃?", vbYesNo, "连接失败:")
If box = vbYes Then
i = 0
Exit Do
Else
i = 0
End If
End If
End If
DoEvents
Loop
lenth = 0
'检查是否与服务器连接
If sockClient.State = sckConnected Then FileName = VB.App.Path & "\1.doc" '取得文件名及路径
lngFile = FileLen(FileName) '取得文件长度
ReDim myFile(lngFile - 1) As Byte '初始化数组
Open FileName For Binary As #1 '打开文件
Get #1, , myFile '将文件写入数组
Close #1 '关闭文件 sockClient.SendData myFile '发送 Else
MsgBox "没有连接"
End If
End Sub'******************************************************************Private Sub sockServer_DataArrival(Index As Integer, ByVal bytesTotal As Long)
'接收文件
Static i As Long
Dim myFile() As Byte
Dim myLong As Double
Dim myPath As String
myPath = VB.App.Path & "\a.doc"
cmdC.Caption = "正在接收数据... " & bytesTotal
ReDim myFile(0 To bytesTotal - 1) '此处也可以是(0 To bytesTotal-1)
sockServer(Index).GetData myFile
i = i + 1
Open myPath For Binary As #1 '新建文件
Put #1, lenth + 1, myFile '将收到的数据写入新文件中
Close #1 '关闭
'记录文件长度
lenth = lenth + UBound(myFile) - LBound(myFile) + 1
End Sub'******************************************************************
请问接收的计算机是否也要装一个程序呢-_-!
我的意思是程序只在本机运行~
地址栏输入\\ip地址
如:\\192.168.0.22
登陆后看你要到那个盘去都可以.
如到c盘: \\192.168.0.22\c$
这样就Ok了不知道楼主要的是不是这样的.呵呵
如果知道用户名、密码及IP地址就可以直接传输了
地址栏输入\\ip地址
如:\\192.168.0.22
登陆后看你要到那个盘去都可以.
如到c盘: \\192.168.0.22\c$
这样就Ok了不知道楼主要的是不是这样的.呵呵
=================================
把这个过程写在程序里面就ok了,前提是对方开机,你知道密码.
汗....那你直接U盘过去得了,这么费劲干嘛?