How to get the file creation date of a file?
Asked Answered
B

1

5

How to get the creation date of a PDF file in Microsoft Dynamics AX 2009 with X++?

And how to open that PDF file in the button click?

Baumgardner answered 5/1, 2012 at 5:58 Comment(0)
W
7

There is no build in function to do that, but you could ask Windows.

The WinAPi getFileTime function returns a filetime structure. However both the parameters and the return value is a little difficult to interface to (look at other function in the AX WinAPI class).

Much easier is the interface to the .Net getCreationTime method (do be defined in WinAPI):

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

To be used like:

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

To open a PDF or whatever file using the default viewer:

WinAPI::ShellExecute(@"C:\test.pdf");
Weed answered 5/1, 2012 at 8:30 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.