Aspose System Unauthorized Access Exception

48 views Asked by At

When trying to implement Aspose sample code below I'm getting System.UnauthorizedAccessException because it's trying to save to a forbidden directory.

I have a known server path to output this file correctly, but I didn't find how to setup Aspose on this server path. How can I set the output directory?

    public JsonResult ConvertPDFtoXLSX(FormCollection formCollection)
    {
        var inputFile= Request.Files[0];

        // load PDF with an instance of Document                        
        var document = new Document(inputFile.InputStream);

        // save document in XLS format
        document.Save("output.xlsx", new ExcelSaveOptions());

        return Json(new
        {
            success = true,
        }, JsonRequestBehavior.AllowGet);
    }
1

There are 1 answers

0
rd1218 On

Solution was simply replace "output.xlsx" with the complete server path (filename included).