Learning OS.File
[email protected] Tue, 16 Dec 2014 07:13:15 -0800 (PST)
| Newsgroups | gmane.comp.mozilla.devel.xpfe |
|---|---|
| Message-ID | <[email protected]> |
I'm starting to delve into OS.File in preparation for moving away from nsIFile in a XUL app I have. I've set up a simple test script to try to read in a small text file containing 25 lines of CSV text. However, I can't seem to get it to read the file (or at least get to the data it reads in). My test code looks like this:
Components.utils.import("resource://gre/modules/osfile.jsm");<BR>
let deskDir = OS.Constants.Path.tmpDir;<BR>
let testFile = OS.Path.join(deskDir,"testFiles","csvTest.txt");<BR>
let csvContents = OS.File.read(testFile);
From the info on here and on the "OS.File for the main thread" page, this should read my text file into csvContents as array. However, trying to access the elements of the array give me an undefined (i.e. - alert(csvContents[0]);.
Can someone point me in the right direction?