Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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?

like image 505
Revathi Avatar asked Jan 05 '12 05:01

Revathi


1 Answers

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");
like image 98
Jan B. Kjeldsen Avatar answered Sep 30 '22 07:09

Jan B. Kjeldsen