我写的FTP上传程序上传只有数字的文本文件,上传成功后,里面格式不变,但只要有汉字在里面,上传后的文件格式就乱了,还有乱码,里面的内容也有的无故丢失,这该怎么办啊,急急急!

解决方案 »

  1.   

    我的上传程序代码如下:Private Sub UpLoadFile(strSourcePlace As String, strPlaceOfUp As String, strFileName As String)
    Dim Cnt As Long, nFileLen As Long, nRet As Long, nTotFileLen As Long
    Dim sBuffer As String * 1024
    Dim Ret As Long, SentBytes As Long, sAllBytes As Long, z As Long
    Dim i As Integer, StartT As Long
    Dim Kam As String, Ode As StringDim strPath     As String
    strPath = strSourcePlace
    g_Klic = strPlaceOfUpOde = strPath & strFileName    '源文件
    Kam = g_Klic & strFileName        '目标文件
    txtInfo.SelText = Time & " > 开始文件传送..." & vbCrLf & " > 上传来源: " & Ode & ", 到: " & Kam & vbCrLf
    txtInfo.SelText = Time & "> 正在上传文件资料...等待中" & vbCrLfhFile = FtpOpenFile(g_server, Kam, GENERIC_WRITE, FTP_TRANSFER_TYPE_BINARY, 0)
    If hFile = 0 Then
                
      
        MsgBox "不能在服务器上创建文件", vbExclamation, App.Title
        txtInfo.SelText = Time & " > 不能在服务器上创建文件! 要求中止!" & vbCrLf
                    
        Unload Me
                 
                    
    End IfSentBytes = 0
    nFileLen = 0
    StartT = GetTickCountOpen Ode For Binary As #1
        nTotFileLen = LOF(1)
            Do
                Get #1, , sBuffer
                If nFileLen < nTotFileLen - sReadBuffer Then
                    If InternetWriteFile(hFile, sBuffer, sReadBuffer, nRet) = 0 Then
                        MsgBox "Nastala chyba p鴌 p鴈vodu dat!", vbExclamation, App.Title
                        txtInfo.SelText = Time & " > Nastala chyba p鴌 p鴈vodu dat! Po瀉davek stornov醤!" & vbCrLf
                        Exit Do
                    End If
                          
                    nFileLen = nFileLen + sReadBuffer
                Else
                    If InternetWriteFile(hFile, sBuffer, nTotFileLen - nFileLen, nRet) = 0 Then
                        MsgBox "Nastala chyba p鴌 p鴈vodu dat!", vbExclamation, App.Title
                        txtInfo.SelText = Time & " > Nastala chyba p鴌 p鴈vodu dat! Po瀉davek stornov醤!" & vbCrLf
                        Exit Do
                    End If
                          
                    nFileLen = nTotFileLen
                End If
                       
                          
            Loop Until nFileLen >= nTotFileLen
    Close
               
        InternetCloseHandle hFile
        txtInfo.SelText = Time & " > 文件传送完毕" & vbCrLf
        
        
    '移走文件
    'Call MoveFile
    'MsgBox "文件传送完毕.", vbInformation
    'Unload Me
    End Sub