The following is a snippet of code from a method that writes a csv file attachment to the desktop (or, as you can see in the code, the app server) then reads it and then passes it to another method to be processed.
This method runs fine in Developer but errors out in the Smart Client (‘Problem reading text file’).
I am a bit stumped as to why this works in one and not the other…
if(utils.stringPatternCount(attachName.toLowerCase(),'.csv')){//if csv format
var attachmentDataByteArray = attachment.getData();
//write attachmentDataByteArray to a file...
var desktop = plugins.file.getDesktopFolder();
var fileName = desktop+'\/zz'+attachName;
//var fileName = './server/webapps/ROOT/zz'+attachName; //also tried this path as well
var success = plugins.file.writeFile(fileName,attachmentDataByteArray);
if (success){
var vTextFile = plugins.file.readTXTFile(fileName);
if(!vTextFile){ plugins.dialogs.showWarningDialog('Warning', 'Problem reading text file', 'OK'); }
else {
UpdateStatusFromCSVReport(vTextFile);
plugins.file.deleteFile(fileName);
}
}
else { plugins.dialogs.showWarningDialog('Warning', 'Problem writing text file', 'OK'); }
}
Version 3.1.6-build 410
Java version 1.5.0_10-b03 (Windows XP)
MySQL 5