看别人写的文件分割工具挺好用,也学着写了一个,附源代码。[5]

[入库:2005年8月18日] [更新:2007年3月24日]

本文简介:选择自 fling_boy 的 blog

            if readsize > filesize then
                '如果文件所剩余大小比当前选择的小,就使用剩余大小.
                readsize = filesize
                redim varr(1 to readsize)
            end if
           
            get fnum, i * itemsize + 1, varr
            i = i + 1
           
            fnum2 = freefile()
           
            open trim(txtobject.text) & "\" & trim(str(i)) & "_" & filename for binary as fnum2
'            if i = 1 then put fnum2, , splitfiles
            put fnum2, , varr
            close fnum2
           
            filesize = filesize - readsize
            '文件总大小减少.
        wend
        close fnum
       
        msgbox "分割成功.", vbokcancel, "提示信息"
    else
    '分割
        dim findfile as boolean
        dim filepath as string
        '是否还有后继文件标志
        findfile = true
        filename = right(vfile, instr(strreverse(vfile), "\") - 3)
        filepath = left(vfile, len(vfile) - instr(strreverse(vfile), "\") + 1)
        '求原始文件名称
       
        fnum = freefile()
        open trim(txtobject.text) & "\" & filename for binary as fnum
       
  
        while findfile
            fnum2 = freefile()
           
            open vfile for binary as fnum2
            filesize = lof(fnum2)
            if filesize > 0 then
                redim varr(1 to filesize)
               
                get fnum2, 1, varr
                put fnum, , varr
                close fnum2
            end if
            i = i + 1
            if dir(trim(str(i + 1)) & "_" & filename) = "" then findfile = false
            vfile = filepath & trim(str(i)) & "_" & filename
        wend
       
        close fnum
       
        msgbox "合并成功.", vbokonly, "提示信息"
    end if
end function


private sub cmdfind_click()
dim tmppath as string

    showdir me.hwnd, tmppath
    if trim(tmppath) <> "" then
        txtobject.text = trim(tmppath)
    end if
end sub

private sub cmdselectfile_click()

本文关键:文件分割
  相关方案
Google
 

本站最佳浏览方式为 分辨率 1024x768 IE 6.0(或更高版本的 IE浏览器)

go top