如何获取文件的创建日期?

5
如何使用X++在Microsoft Dynamics AX 2009中获取PDF文件的创建日期?如何在按钮点击时打开该PDF文件?
1个回答

7

没有内置的函数可以做到这一点,但您可以向Windows询问。

WinAPI getFileTime 函数返回一个 filetime 结构。然而,参数和返回值都有些难以接口化(请查看 AX WinAPI 类中的其他函数)。

更容易的接口是 .Net getCreationTime 方法(在 WinAPI 中定义):

client static UTCDateTime getFileCreationTime(str name)
{
    return CLRSystemDateTime2UtcDateTime(System.IO.File::GetCreationTime(name));
}

使用方法如下:

static void Job1(Args _args)
{;
    info(strFmt("%1", WinAPi::getFileCreationTime(@"C:\Users\zjbk\My Documents\ActionTool_SysFlushDictionaryServer.xpo")));
}

使用默认查看器打开PDF或其他文件的方法如下:
WinAPI::ShellExecute(@"C:\test.pdf");

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接