Revathi
Revathi

Reputation: 307

How to get the file creation date of a file?

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?

Upvotes: 5

Views: 2606

Answers (1)

Jan B. Kjeldsen
Jan B. Kjeldsen

Reputation: 18051

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");

Upvotes: 7

Related Questions