你可以用ftp  来传送,不过要用ftp  ,需要将其中一台配置成ftp 服务器才行。
配置好ftp 服务器后,用ftp.exe 这个文件来传文件,可以从程序中调用,它也支持批命令,具体的可以看ftp.exe 的帮助。我原来做过用FTP传文件的,不过文件没有这么大。另:传之前可以先压缩。

解决方案 »

  1.   

    不行!!! 这个程序必须自己用 winsock 来传送文件!!!
    主机上和客户端上都必须用 winsock 自己来完成!!
    而且不能采用对文件压缩的方式
      

  2.   

    主要思想是:把文件用2进制方法读出来!放到数组里去!一个数组元素放一小块文件!!然后用winsock一个一个文件块发过去,在另一端用put把文件块放回到文件中(组合起来)
    大致的思路就是这样的
      

  3.   

    我知道方法是这样的
    但是超过10M后也就很多问题了
    再说了数组还是要动态2维的!!!
    因为我还要对应到不周数组的 Winsock 控件上
    请问还有没有更好的方法!!!!
      

  4.   

    动态数组你可以用erase 然后Redim 数组,就是动态的数组了。
    至于,超过10m有很多问题,具体有哪些问题,我很感兴趣。我也刚写了文件传输的控件,只是没有碰到这么大的文件。
      

  5.   

    你先说说你怎么处理的?
    你不会只是一对一传吧??我这里必须要 一 对 N 传!!
    如果拆包的话就要为每个 Winsock 做一个数组保存数据(指还没有发送的数据)
    还有就是 10M 的文件也太大了!!就是拆数组也要用太大的内存去放了!
    你不觉得要是有个三五个人一起下这些文件你的主机会当机吗?
    对了, 你可以说说你传的是多大的文件吗?
      

  6.   

    一对多的传输,只要用winsock数组就可以了啊,用完一个就卸掉一个在load 一个。同一时间传多个用户我没试过,觉得不太保险。你可以试试,存放文件的数组一个就够了啊,为什么要一个winsock一个数组啊,这样写的话,内存肯定不够啊,即使是1m的文件要有个1000个人下,那不是完蛋了。我想是给连接进来用户排个队,一个一个传。不然系统资源怎么可能够用?
    我的控件是1对1的,有多个用户也是有先后的传的,全程只用一个数组存放文件。
    还有,如果文件很大了,的确会占太大的内存,我想是不是可以,给数组放个限制,比如超过5m的文件就先读文件的前5m进数组,传完了后再继续前面的文件读后5m进数组,循环利用。就不太占资源了。
      

  7.   

    拆文件的一个函数
    Public Function DivideFile(ByVal FileToDivide As String)
    On Error GoTo Errorhandler
    strFileName = FileToDivide
        lngSendFileNum = FreeFile()   '打开空文件号    '清楚数组,为后面重新定义
            Erase strDataChunk()
            Erase lngPosition()    '取得最后一个包的大小
            lngFileSize = (FileLen(strFileName))
            NpFileLen = lngFileSize  '赋值给FileLen属性
            lngPacketSize = 4096     '数据包大小
            
        '取得整个文件打包数
            If lngFileSize < lngPacketSize Then
                        LngChunkPacks = 1
                        ReDim strDataChunk(LngChunkPacks)
                        ReDim lngPosition(LngChunkPacks)
            Else
                        lngLastChunkSize = lngFileSize Mod lngPacketSize
                        LngChunkPacks = Val(lngFileSize \ lngPacketSize + 1)
                        ReDim strDataChunk(LngChunkPacks)
                        ReDim lngPosition(LngChunkPacks)
            End If
         
         '打开要传输的文件
            Open strFileName For Binary As lngSendFileNum
            position = 1
            For lngIndex = 1 To LngChunkPacks
                strDataChunk(lngIndex) = Input(lngPacketSize, lngSendFileNum)    '往数组里写入取得文件分割的数据块
                lngPosition(lngIndex) = position     '数据块在文件中的位置
                position = position + lngPacketSize  '数据块在文件中的位置-标记
                LngLocPos = Loc(lngSendFileNum)  '返回一个 Long,在已打开的文件中指定当前读/写位置
                LngSeekPos = Seek(lngSendFileNum) '返回一个 Long,在 Open 语句打开的文件中指定当前的读/写位置。
    Next lngIndex
                
    Close'检查数据包是否正确
    If lngFileSize < lngPacketSize Then
        TestRetval = Len(strDataChunk(1))
            If TestRetval = lngFileSize Then
            Pause (200)
            '数据检查无误
            Else
            Pause (200)
            '数据检查有误   错误赋值
            Error ("数据检查有误")
            Exit Function
            End If
    Else
        TestRetval = ((LngChunkPacks - 1) * lngPacketSize) + lngLastChunkSize
            If TestRetval = lngFileSize Then
            Pause (200)
            '数据检查无误
            Else
            Pause (200)
            '数据检查有误   错误赋值
            Error ("数据检查有误")
            Exit Function
            End If
    End If
    Exit FunctionErrorhandler:
    NpGetError = Err.Description
    Err.Clear
    End Function
      

  8.   

    //下面的代码既是服务器又是客户端
    //采用应答式发送方式
    //自动拆分文件,包括2进制
    //我用它传过星际争霸的最大那个mpq文件>100M
    'Author:Dah
    'Coded time:2000.11.10  //y.m.d
    'Usage:transfer a file to another pc through intranet with winsock power
    Option Explicit
    Dim mybyte() As Byte  '发送方数组
    Const filecomesMSG = "a file is coming "  '有文件到来
    Const RemoteIsReadyMSG = "I'm ready        "  '准备好了
    Const FileisOverMSG = "the file is ended"  '文件完毕
    Const RemoteDenyMSG = "the user canceled"
    Const filecountMSG = "the file lengh is"
    Dim arrdata() As Byte  '收到的信息
    Dim filesave As Integer  '保存文件的句柄
    Dim filehandle As Integer  '发送方文件的句柄
    Dim MyLocation As Double
    Dim myMSG As String  '消息
    Dim FileisTransfer As Boolean  '文件正在传送
    Dim Isendfile As Boolean  '是否是本人在传送
    Dim FileisOver As Boolean  '文件是否已经完毕
    Dim Counttime As Integer '需要传递的次数
    Dim totaltime As Variant
    Private Sub cmdsend_Click()
    On Error GoTo errorhandle
    'this is needed for correct filename
    filehandle = FreeFile
    If Mid(File1.Path, Len(File1.Path), 1) = "\" Then
    Open File1.Path & File1.FileName For Binary Access Read As #filehandle
    Else
    Open File1.Path & "\" & File1.FileName For Binary Access Read As #filehandle
    End If
    Isendfile = True  '是本人在传送
    FileisOver = False  '文件刚开始
    cmdsend.Enabled = False
    Label1.Caption = "Wait for reply..."
    MsgBox ("the selected file size is " & LOF(filehandle) & " bytes")
    totaltime = Int(LOF(filehandle) / 4000 + 1)
    MyLocation = Loc(filehandle)
    Winsock.SendData filecomesMSG & File1.FileName    '发送发出文件信息
    Winsock.SendData filecountMSG & totaltime
    Exit Sub
    errorhandle: MsgBox ("You havn't choose a file!")
    End SubPrivate Sub Dir1_Change()
    File1.Path = Dir1.Path
    End SubPrivate Sub Drive1_Change()
    Dir1.Path = Drive1.Drive
    End SubPrivate Sub Form_Load()
    Drive1.Drive = "c:\"
    Winsock.RemoteHost = "255.255.255.255"
    Winsock.LocalPort = 7904
    Winsock.Bind 7904
    Winsockfile.RemoteHost = "255.255.255.255"
    Winsockfile.LocalPort = 7905
    Winsockfile.Bind 7905
    FileisTransfer = False  'initialize the bool value
    Isendfile = False
    FileisOver = True
    Counttime = 0
    Label1.Caption = "Ready..."
    End SubPrivate Sub Timer1_Timer()
    Dim i As Integer
    If LOF(filehandle) - MyLocation > 4000 Then
    ReDim mybyte(0 To 4000)
    Get #filehandle, , mybyte
    MyLocation = Loc(filehandle)
    Winsockfile.SendData mybyte
    Counttime = Counttime + 1
    Label1.Caption = "the select file is being transfered..." & "about " & Counttime & " / " & totaltime
    Timer1.Enabled = False
    Else
    ReDim mybyte(0 To LOF(filehandle) - MyLocation - 1)
    Get #filehandle, , mybyte
    Winsockfile.SendData mybyte
    FileisTransfer = False
    Timer1.Enabled = False
    FileisOver = True
    End IfEnd SubPrivate Sub Winsock_DataArrival(ByVal bytesTotal As Long)
    Winsock.GetData myMSG
    Select Case Mid(myMSG, 1, 17)
    Case filecomesMSG    '这些消息发送方和接受方都可收到
    'do display a form
    If Not Isendfile Then  '接受方处理这些事情
    On Error GoTo errorhandle
    CommonDialog1.FileName = Mid(myMSG, 17, Len(myMSG))
    CommonDialog1.ShowSave
    filesave = FreeFile
    FileisTransfer = True
    cmdsend.Enabled = False
    Open CommonDialog1.FileName For Binary Access Write As #filesave
    Winsock.SendData RemoteIsReadyMSG
    Label1.Caption = "the select file is being transfered..."
    End If
    Case RemoteIsReadyMSG
    'do begin transfer a file
    '如果文件还没有结束,也就是说,只有主机才能受到
    If Isendfile Then
    If Not FileisOver Then
    Timer1.Enabled = True
    Label1.Caption = "the select file is being transfered..."
    Else
    Winsock.SendData FileisOverMSG
    End If
    End If
    Case FileisOverMSG
    If Not Isendfile Then '客户机处理
    Close #filesave
    FileisTransfer = False
    Else  '主机处理
    Isendfile = False
    Close #filehandle
    End If
    MsgBox ("the file is transfered successfully!")  '大家一起处理
    Isendfile = False
    cmdsend.Enabled = True
    Label1.Caption = "Ready..."
    Case RemoteDenyMSG
    If Isendfile Then
    MsgBox ("The user canceled this transfer session!")
    Isendfile = False
    FileisOver = True
    cmdsend.Enabled = True
    Label1.Caption = "Ready..."
    Close #filehandle
    End If
    Case filecountMSG
    If Not Isendfile Then
    totaltime = Mid(myMSG, 17, Len(myMSG))
    End If
    End Select
    Exit Sub
    errorhandle: Winsock.SendData RemoteDenyMSG
    End Sub
    Private Sub writetofile()
    Put #filesave, , arrdata
    End SubPrivate Sub Winsockfile_DataArrival(ByVal bytesTotal As Long)
    If FileisTransfer Then
    Winsockfile.GetData arrdata, vbArray + vbByte, 4001
    writetofile
    Winsock.SendData RemoteIsReadyMSG
    Counttime = Counttime + 1
    Label1.Caption = "the select file is being transfered..." & "about " & Counttime & "/" & totaltime
    End If
    End Sub
      

  9.   

    toNew_Apollo(阿波罗):如果需要工程文件,请留email
      

  10.   

    [email protected]小弟对此很感兴趣。可否给我发一个啊
      

  11.   

    to gameboy999也发一个给小弟吧,谢谢了[email protected]
      

  12.   

    to gameboy999
    n能给我一个吗,感激不禁,[email protected]
      

  13.   

    我有一个VC版的,是TFTP服务器端程序。有谁要,来email:[email protected]
      

  14.   

    到网上找一个FTP服务器的源程序.
      

  15.   

    to gameboy999(我心迷茫):
       能发一个给我吗?EMail:[email protected]
    谢谢!
      

  16.   

    I need it,too!Thanks.
    [email protected]
      

  17.   

    无论多大的文件我都传过,能传1M就能传1000M,我的代码在www.vchelp.net上
      

  18.   

    无论多大的文件我都传过,三十年孤独之饱经沧桑自由聊天。
    早已实现,可以到此处去下载:
    http://www.csdn.net/filebbs/read_topic.asp?id=517 
      

  19.   

    可以采用异步机制发送。比如每次发1k,然后发送消息(post)请求继续写,这样不会出现白框问题。
      

  20.   

    To:New_Apollo(阿波罗)给代码, 我给分啊!
    [email protected]