江郎才尽 发表于 2011-5-27 23:38:50

如何写把文件输出为16进制的数据

本帖最后由 江郎才尽 于 2011-5-27 23:49 编辑

如何写把文件输出为16进制的数据


$file = FileOpen("test.png", 0)
$file1 = FileOpen("test.txt", 16)

While 1
    $chars = FileRead($file,1)
If @error= -1 Then
    ExitLoop
Else
        FileWrite($file1, $chars)
EndIf       
Wend

FileClose($file1)
FileClose($file)

Exit


上面的这个代码不行

suiyefeng 发表于 2011-5-28 09:56:31

本帖最后由 suiyefeng 于 2011-5-28 11:04 编辑

提供个思路...
$file = FileOpen("test.png", 16)
$file1 = FileOpen("test.txt", 2)
Dim $m = 0
While 1
    $chars = (FileRead($file,4))
        If @error= -1 Then
                ExitLoop
        Else
                $chars=String($chars)
                $chars=StringMid($chars,3)
                $m = $m + 1
                FileWrite($file1,$chars)
                If $m = 4 Then
                        FileWrite($file1,@CRLF)
                        $m=0
                EndIf
        EndIf
Wend

FileClose($file1)
FileClose($file)

Netfox 发表于 2011-6-9 00:37:20

有点困难。。
页: [1]
查看完整版本: 如何写把文件输出为16进制的数据