我想在firefox中使用javascript将文件写入文件

时间:2013-11-18 18:57:31

标签: javascript

我遇到的问题是component.classes在调试器中传递了未定义的component.class.please sugest me

<html>
    <head>
    <meta charset="utf-8">
    <script language="javascript">
     function Write ()
        {
    var file1 = Components.classes["@mozilla.org/file/local;1"].createInstance(Components.interfaces.nsILocalFile);
    file1.initWithPath("D:\\Gyan.txt"); 

    var foStream = Components.classes["@mozilla.org/network/file-output-             stream;1"].createInstance(Components.interfaces.nsIFileOutputStream);
    // use 0x02 | 0x10 to open file for appending.
    foStream.init(file1, 0x02 | 0x08 | 0x20, 438, 0);
    var converter = Components.classes["@mozilla.org/intl/converter-output-stream;1"].
                    createInstance(Components.interfaces.nsIConverterOutputStream);
    converter.init(foStream, "UTF-8", 0, 0);
    converter.writeString("test string");
    converter.close(); // this closes foStream
        }     
    </script>
    </head>
    <body onLoad="Write('\D:\\Gyan.txt','pankaj')">
    </body>
    </html>

0 个答案:

没有答案