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

Copy Markup charges while posting purchase invoice using X++

 Copy Markup charges while posting purchase invoice using X++ Class: Important: Code logic is just for Reference.  New class => Duplicate...