import win.ui;
/*DSG{{*/
var winform = win.form(text="读目录文件实例";right=759;bottom=469)
winform.add(
buttonClose={cls="button";text="退出";left=420;top=353;right=528;bottom=401;color=14120960;font=LOGFONT(h=-14);note=" ";z=3};
buttonReadDir={cls="button";text="读取目录";left=141;top=353;right=283;bottom=402;color=14120960;font=LOGFONT(h=-14);note=" ";z=2};
listview={cls="listview";left=114;top=39;right=685;bottom=325;edge=1;fullRow=1;z=1}
)
/*}}*/
//aardio读取目录文件(按修改时间倒序)
import fsys;
import fsys.file;
import time;
import console;
var saveDir = io.fullpath(".")++"\rich\";
if _STUDIO_INVOKED saveDir="D:\1_aardio\rich\";
var dataTable = {}
//读目录:修改时间排序
winform.readDir = function(){
dataTable = {};
dataTable['fields']={"file","fileTime"};
fsys.enum( saveDir, "*.txt",
function(dirPath,fileName){
var f = fsys.file(saveDir++fileName,"r");
fileTime = time(tonumber(f.getTime().write),"%Y-%m-%d %H:%M:%S")
f.close();
table.push(dataTable,{"file"=fileName,"fileTime"=fileTime});
}
);
//时间大到小排序
table.sort(dataTable,function(b){
return b.fileTime<owner.fileTime
});
//console.dump(dataTable)
}
winform.buttonReadDir.oncommand = function(id,event){
winform.readDir()
winform.listview.setColumns({"文件","修改时间(倒序)"},{200,100}); //标题
winform.listview.setTable(dataTable)
winform.listview.fillParent(); //最后一列填满
}
winform.buttonClose.oncommand = function(id,event){
win.quitMessage()
}
winform.show();
win.loopMessage();