The powerfully WinApi-Function 'MakeSureDirectoryPathExists' implementet in X++!
The MakeSureDirectoryPathExists function creates all the directories in the specified _filePath, beginning with the root.
This function resides in imagehlp.dll, but also in
dbghelp.dll.
Take a look to http://msdn2.microsoft.com/en-us/library/ms680352.aspx
static int MakeSureDirectoryPathExits(FilePath _filePath)
{
/*
fa 20061102
Returnvalue:
0... OK
>0.. Error
*/
#define.imagehlp('imagehlp.dll')
DLL winApiDLL = new DLL(#imagehlp);
DLLFunction pathExits = new DLLFunction(winApiDLL, 'MakeSureDirectoryPathExists');
int retVal = 0;
;
if(substr(_filePath, strlen(_filePath), 2) != "\\")
_filePath += "\\";
pathExits.returns(ExtTypes::DWord);
pathExits.arg(ExtTypes::String);
if (pathExits.call(_filePath) == 0)
{
retVal = WinAPI::getLastError();
retVal = retVal == 0 ? 1 : retVal;
}
return retVal;
}
Thursday, November 02, 2006
Subscribe to:
Post Comments (Atom)
1 comment:
Hi there, I love your blog! Keep it up, the effort is paying off :) Just in case you still haven't seen it, check out https://ax-dynamics.com/ for fresh updates of what is up with Microsoft Dynamics software and great offers :)
Cheers!
Post a Comment