Can load text file in Windows - not on the Mac?
I have some code that loads a text file into an array that works fine in windows, but fails on the Mac I'm sure it's a path issue but I've spent several hours trying to work this out.
Windows code works fine:
var textPath = "c:\\temp\\textfile.txt";
try {
var myFile = File(textPath);
var mymenuItems=[];
var menuItems=[];
myFile.open('r');
while(!myFile.eof){
mymenuItems.push(myFile.readln());
}
myFile.close();
Mac Code Fails
var textPath = '/User/wizbowes/Desktop/text.txt';
try {
var myFile = new File(textPath); //tried both with and without new - same effect
var mymenuItems=[];
var menuItems=[];
myFile.open('r');
while(!myFile.eof){
mymenuItems.push(myFile.readln());
}
When debugging on the mac myFile.eof shows true straight after I open the file and therefore never enters the loop to populate the array
What on earth am I doing wrong?
