Thursday, June 5, 2014

Rar Conversion Through X++

// Rar Conversion Through X++
static void rarconversion(Args _args)
{
    WinAPI::shellExecute("C:\\Program Files\\WinRAR\\WinRAR.exe",
        "a -afzip -df c:\\test.zip C:\\xls");
}
//C:\\PurchPurchaseOrderReport.pdf;
//c:\\code.txt
//


    CodeAccessPermission    perm;
    System.Exception        ex;

    str filePath    = @'C:\Temp\TestZipFolder';
    str zipPath     = @'C:\Temp\test.zip';
    str extractPath = @'C:\Temp\UnZip';

    try
    {
        perm = new InteropPermission(InteropKind::CLRInterop);
        perm.assert();

        //Archive folder content to file
        System.IO.Compression.ZipFile::CreateFromDirectory(filePath, zipPath);

        //extract Zip to folder
        System.IO.Compression.ZipFile::ExtractToDirectory(zipPath, extractPath);

        CodeAccessPermission::revertAssert();
    }

    catch (Exception::CLRError)
    {
        ex = ClrInterop::getLastException();
        if (ex != null)
        {
            ex = ex.get_InnerException();
            throw error(ex.ToString());
       }
    }

No comments:

Post a Comment

Convert Call stack to readable format in D365FO X++

//Input --container _xppCallStack = xSession::xppCallStack();  Public static str POL_formatXppCallStack(container _xppCallStack, int _skipFr...