Hello there
Thank you for the example code. I've had it working using the server build. So I switched over to my ISAPI project where it also worked in debug mode.
However, when I do a release build, the file doesn't get served - It appears that the path I'm using doesn't exist, so please advise which
In debug inside builder, when I create my PDF file this is the location...
C:\Users\icaru\AppData\Local\Temp\01d2hlems0\user\TQpucrrKel5-GK9lReBKX05yXdq
In release outside of Builder, when I create my PDF file this is the location...
C:\WINDOWS\TEMP\01d2hlyb7v\user\wbKedcHYwhsQH4blNu6GiBdRJaa
I added a directory exists check and in debug this passes, but in release it doesn't. What should I be using in release mode?
Here's my example code...
// Path for generated file and file name for the file
AnsiString sPath = WebApplication->UserCacheDir;
AnsiString sPathFile = sPath + String("contents.pdf");
// test message for release build testing, confirm generated file location
WebApplication->ShowMessage(sPath);
// test message for release build testing, check directory
WebApplication->ShowMessage("directory exist check");
if (System::Sysutils:

irectoryExists(sPath))
WebApplication->ShowMessage("directory exists");
else
WebApplication->ShowMessage("directory does NOT exist")
// Object for creating the PDF file
TContentsScreenPDF* oPDFIt = new TContentsScreenPDF(NULL, oSession->oSys, oSession->oDM, oContentsList);
// test message for release build testing
WebApplication->ShowMessage("generate PDF");
// Generate PDF
if (oPDFIt->Export(sPathFile.c_str(), "Contents Report")) {
// test message, confirm generate worked
WebApplication->ShowMessage("PDF created");
// PDF generated, copy it to cache
String sTempFileName = TIWAppCache::NewTempFileName();
String sFileUrl = oSession->WebApplication->CacheFiles->Add(sFileName);
FileCopy(sPathFile, sTempFileName, true);
String sURL = TIWAppCache::AddFileToCache(this, sTempFileName, TIWMimeTypes::GetAsString(mtPDF), ctOneTime);
// Serve up the file
WebApplication->NewWindow(sURL);
}