110,557
社区成员
发帖
与我相关
我的任务
分享
//读取当面目录中最新的MDB文件
private string getlastWriteMdbfile(string path)
{
string rfn = "";
try
{
DateTime lstdt = new DateTime();
foreach (string f in System.IO.Directory.GetFiles(path, "*.mdb", System.IO.SearchOption.AllDirectories))
{
System.IO.FileInfo fi = new System.IO.FileInfo(f);
if (rfn == "")
{
lstdt = fi.LastWriteTime;
rfn = f;
}
else
{
if (fi.LastWriteTime > lstdt)
{
lstdt = fi.LastWriteTime;
rfn = f;
}
}
}
addlog ("获得文件名---"+rfn);
}
catch (Exception ex)
{
addlog("发生错误---" + ex.Message);
//错误日志中经常出现 “发生错误---The path is not of a legal form.”
}
return rfn;
}
if (!string.IsNullOrWhitespace(f))
{
System.IO.FileInfo fi = new System.IO.FileInfo(f);
}