本帖最后由 夜猫猫 于 2011-3-11 03:47 编辑
比如1文件夹下有1.txt,1.txt.3.txt
1.txt内容为1111111111
2txt内容为2222222222
3.txt内容为3333333333
怎么读取他们,并将所有内容合并一起为4.txt
4.txt内容为其他三个txt的合并内容
即:4.txt
1111111111
2222222222
3333333333
下面是获取文件路径:#include <File.au3>
#include <GUIConstantsEx.au3>
#Region ### START Koda GUI section ### Form=
Global $str, $file, $hFile, $FileList, $folder
$Form1 = GUICreate("", 473, 189, 192, 114)
$Input1 = GUICtrlCreateInput("", 48, 136, 225, 21)
$Button1 = GUICtrlCreateButton("读取", 220, 160, 57, 21)
$Button2 = GUICtrlCreateButton("打开", 300, 136, 57, 21)
$Edit1 = GUICtrlCreateEdit("", 8, 8, 441, 113)
GUISetState(@SW_SHOW)
Func Ru()
$FileList=_FileListToArray($folder)
$file=FileOpen ("log.log",2)
For $i = 1 To $FileList[0]
FileWriteLine ($file, $folder&""&$FileList[$i])
Next
FileClose($file)
EndFunc
While 1
$nMsg = GUIGetMsg()
Switch $nMsg
Case $GUI_EVENT_CLOSE
Exit
Case $Button1
Case $Button2
$folder = FileSelectFolder("选择一个文件夹", "",1+4,"")
If Not @error Then
Ru()
GUICtrlSetData($Edit1, "")
GUICtrlSetData($Edit1, FileRead(@ScriptDir&"\log.log"))
EndIf
EndSwitch
WEnd
|