[Jslib] Opening files in Windows

Pete Collins pete at mozdevgroup.com
Mon Aug 2 10:55:02 EDT 2004

> What is the path I pass to File constructor?  I tried
> var f = new File('file:///C|/foo/bar.txt');

var f = new File("c:\\foo\\bar.txt");

Note the double slashes. This is a javascript issue since js will think 
you are trying to escape the "f" and "b" in "c:\foo\bar.txt" string.

For *easily* getting various directories on the system, just use jsLib 


So for example, you could do something like this:

include (jslib_io);

var f = new File(getMozUserHomeDir());

On windows XP this would translate to somthing like:

c:\Documents and Settings\winXPUser\Application Data\ 


Pete Collins - Founder, Mozdev Group Inc.
Mozilla Software Development Solutions 

More information about the Jslib mailing list