找回密码
 加入
搜索
查看: 1387|回复: 4

[AU3基础] [已解決]請問如何讀取到share folder裡面txt的資料?

[复制链接]
发表于 2016-5-19 15:11:16 | 显示全部楼层 |阅读模式
本帖最后由 ipmitool 于 2016-5-19 20:46 编辑

請問如何讀取到share folder裡面txt的資料?
share folder為 \\10.32.15.40\temp\mike\

1.txt
sdfasdfsadfasdadfasdfasdfasdfs!ER#$@sdfasdfsadfasdadfasdfasdfas

2.txt
sdfasdfsad@fasdadfasdfasdfasdfs!ER#$@sdfasdfsadfasdadfasdfasdfas
sdfasdfsadfasdadfasdfasdfasdfs!ER#$@sdfasdfsadfasdadfasdfasdfas

3.txt
sdfsdfsf@w32
dsfgsg@dvsfgds
advsfgfhnjt5
Sdsdfgdgdgh
dsfw43@wrgt35y45@jmryjr

4.txt
advfssfdfbg5324353@wr535t3y
ergergy43@243453
@Vadgwrgwg
VDsaf@gryjhr
#include <Array.au3>
#include <File.au3>
#include <GUIConstantsEx.au3>
#include <GuiListView.au3>
;#include <MsgBoxConstants.au3>


GUICreate("Test Status Management v1.0", 800, 300)
    $idListview = GUICtrlCreateListView("", 15, 15, 550, 268)
    GUISetState(@SW_SHOW)


        $Group4                        = GUICtrlCreateGroup("Function Buttons", 585, 20, 120, 215)
        $Button3                = GuiCtrlCreateButton("PowerReset UUT", 600, 45, 90, 30)
        $Button2                = GuiCtrlCreateButton("BaudRate-9600", 600, 80, 90, 30)
        $Button4                = GuiCtrlCreateButton("SOL", 600, 115, 90, 30)
        $Button1                = GuiCtrlCreateButton("-----", 600, 246, 90, 30)



_GUICtrlListView_AddColumn($idListview, "Tester", 100)
_GUICtrlListView_AddColumn($idListview, "Test Item", 100)
_GUICtrlListView_AddColumn($idListview, "BMC IP", 100)
_GUICtrlListView_AddColumn($idListview, "Count", 60)
_GUICtrlListView_AddColumn($idListview, "Last Record Time", 150)
_GUICtrlListView_SetItemCount($idListview, 5000)

_add_lv_items()
AdlibRegister('_add_lv_items', 5000); 5秒刷新数据

Do
Until GUIGetMsg() = $GUI_EVENT_CLOSE

GUIDelete()



Func _add_lv_items()

while 1

        Local $path, $aFileList, $aNewList[1][2]
        $path = "\\10.32.15.40\temp\mike"
        $aFileList = _FileListToArray($path, "*.txt")



        If IsArray($aFileList) Then

                ReDim $aNewList[UBound($aFileList)][5] ;;;[Col count]
                For $i = 0 To UBound($aFileList) - 1 Step 1
                        $aNewList[$i][0] = $aFileList[$i]
                        $aNewList[$i][1] = FileReadLine($aFileList[$i], 1)
                        $aNewList[$i][2] = FileReadLine($aFileList[$i], 2)
                        $aNewList[$i][3] = FileReadLine($aFileList[$i], 3)
                        $aNewList[$i][4] = FileReadLine($aFileList[$i], 4)

                Next

                _GUICtrlListView_DeleteAllItems(GUICtrlGetHandle($idListview))
                _GUICtrlListView_AddArray($idListview, $aNewList)

        EndIf



$Msg = GUIGetMsg()
        Switch $Msg
                Case $GUI_EVENT_CLOSE
                        Exit
                Case $Button1
        ;        Case $Checkupdate1
        ;        Case $Checkupdate2
        ;        Case $Checkupdate3
        ;        Case $Radio1
        ;        Case $Radio2
        ;        Case $Radio3
                Case $Button2
                        run("Baud9600.exe")
                Case $Button3
                        run("PowerReset.exe")
                Case $Button4
                        run("SOL.exe")
        EndSwitch
WEnd


EndFunc
发表于 2016-5-19 16:58:54 | 显示全部楼层
$o_File = FileOpen("\\10.32.15.40\temp\mike\1.txt")
$t_File = FileRead($o_File)
FileClose($o_File)
MsgBox(0,0,$t_File)
 楼主| 发表于 2016-5-19 17:17:20 | 显示全部楼层
不過我要去讀folder下所有的txt的內容耶...
$path = "\\10.32.15.40\temp\mike\"
$aFileList = _FileListToArray($path, "*.txt")
 楼主| 发表于 2016-5-19 19:39:24 | 显示全部楼层
我搞定了, 加下面這一行就搞定了~
FileChangeDir("\\10.32.15.40\temp\Mike")
 楼主| 发表于 2016-6-7 10:47:41 | 显示全部楼层
請問如何偵測每行資料, 10分鐘沒更新狀態, 就回報msg error呢? 謝謝各位大大
您需要登录后才可以回帖 登录 | 加入

本版积分规则

QQ|手机版|小黑屋|AUTOIT CN ( 鲁ICP备19019924号-1 )谷歌 百度

GMT+8, 2024-11-17 01:45 , Processed in 0.069055 second(s), 19 queries .

Powered by Discuz! X3.5 Licensed

© 2001-2024 Discuz! Team.

快速回复 返回顶部 返回列表