Base64文件编码

Function ReadBinary(FileName)
	Const adTypeBinary = 1
	Dim stream, xmldom, node
	Set xmldom = CreateObject("Microsoft.XMLDOM")
	Set node = xmldom.CreateElement("binary")
	node.DataType = "bin.base64"
	Set stream = CreateObject("ADODB.Stream")
	stream.Type = adTypeBinary
	stream.Open
	stream.LoadFromFile FileName
	node.NodeTypedValue = stream.Read
	stream.Close
	Set stream = Nothing
	ReadBinary = node.Text
	Set node = Nothing
	Set xmldom = Nothing
End Function

Public Function WriteFile_Append(pathway,words)	
    Dim fileSystemObj,fileSpec,logFile,way
    Set fileSystemObj = CreateObject("Scripting.FileSystemObject")
    fileSpec = pathway 
    Set logFile = fileSystemObj.OpenTextFile(fileSpec, 8, true) 
    logFile.WriteLine (CStr(words))
    logFile.Close
    Set logFile = Nothing
End Function

hexVal = ReadBinary("c:\desk_2.png")
Call WriteFile_Append("c:\ttt.txt", hexVal)

编程技巧