Re: [xul-interop] How to Remove file ?

"salah triki" <[email protected]> Thu, 19 Apr 2007 16:29:03 +0100
Newsgroups gmane.comp.lang.xul.general
Message-ID <[email protected]>
--===============1267316146==
Content-Type: multipart/alternative; 
	boundary="----=_Part_54831_13023318.1176996543866"

------=_Part_54831_13023318.1176996543866
Content-Type: text/plain; charset=ISO-8859-1; format=flowed
Content-Transfer-Encoding: 7bit
Content-Disposition: inline

2007/4/18, Christophe Charron <[email protected]>:
>
> Hi,
>
> 2007/4/18, salah <[email protected]>:
> >
> >
> > Hi everyone , :)
> > I try removing /home/user/file.txt file using code bellow but it doesn't
> > work can any one help me
> >
> > ______________________________________________________________________
> > <?xml version=" 1.0" encoding="ISO-8859-1"?>
> > <?xml-stylesheet href="chrome://global/skin/" type="text/css"?>
> > <window
> >     id="findfile-window"
> >     xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul
> > ">
> >     <script>
> >         function delFile() {
> >             var aFile =
> > Components.classes["@ mozilla.org/file/local;1"].createInstance();
> >             if ( aFile instanceof Components.interfaces.nsILocalFile) {
> >                 aFile.initWithPath("/home/user/file.txt");
> >                 aFile.remove (false);
> >             }
> >         }
> >     </script>
> >     <button label="Button 1" oncommand="delFile();"/>
> > </window>
>
>
> What happens ? Any exception caught ? Are you sure having rigths ? Can you
> open it ?
>
>
> ___________________________________________________________________________________
> >
> > --
> > View this message in context:
> > http://www.nabble.com/How-to-Remove-file---tf3601735.html#a10061119
> > Sent from the XUL - User mailing list archive at Nabble.com.
> >
> >
> >
> > -------------------------------------------------------------------------
> > This SF.net email is sponsored by DB2 Express
> > Download DB2 Express C - the FREE version of DB2 express and take
> > control of your XML. No limits. Just data. Click to get it now.
> > http://sourceforge.net/powerbar/db2/
> > _______________________________________________
> > XUL News Wire      - http://xulnews.com
> > XUL Job Postings   - http://xuljobs.com
> > Open XUL Alliance - http://xulalliance.org
> > _______________________________________________
> > xul-talk mailing list
> > [email protected]
> > https://lists.sourceforge.net/lists/listinfo/xul-talk
> >
>
> --
> Cordially
> Christophe Charron
> -------------------------------------------------------------------------
> This SF.net email is sponsored by DB2 Express
> Download DB2 Express C - the FREE version of DB2 express and take
> control of your XML. No limits. Just data. Click to get it now.
> http://sourceforge.net/powerbar/db2/
> _______________________________________________
> XUL News Wire      - http://xulnews.com
> XUL Job Postings   - http://xuljobs.com
> Open XUL Alliance - http://xulalliance.org
> _______________________________________________
> xul-talk mailing list
> [email protected]
> https://lists.sourceforge.net/lists/listinfo/xul-talk
>
> I modify code to catch exception :
.........................
<script>
        function delFile() {
            try {
            var aFile = Components.classes["@mozilla.org/file/local;1
"].createInstance();
              if ( aFile instanceof Components.interfaces.nsILocalFile) {
                aFile.initWithPath("/home/user/file.txt");
                aFile.remove(false);
            }
            }catch ( e) { alert (e) ; }
        }
    </script>
.........................
message obtained is : Permission denied to get property UnnamedClass.classes

------=_Part_54831_13023318.1176996543866
Content-Type: text/html; charset=ISO-8859-1
Content-Transfer-Encoding: 7bit
Content-Disposition: inline

<br><br><div><span class="gmail_quote">2007/4/18, Christophe Charron &lt;<a href="mailto:[email protected]">[email protected]</a>&gt;:</span><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
Hi,<br><br><div><span class="gmail_quote">2007/4/18, salah &lt;<a href="mailto:[email protected]" target="_blank" onclick="return top.js.OpenExtLink(window,event,this)">[email protected]</a>&gt;:</span><span class="q">
<blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
<br>Hi everyone , :)<br>I try removing /home/user/file.txt file using code bellow but it doesn&#39;t<br>work can any one help me<br><br>______________________________________________________________________<br>&lt;?xml version=&quot;
1.0&quot; encoding=&quot;ISO-8859-1&quot;?&gt;<br>&lt;?xml-stylesheet href=&quot;chrome://global/skin/&quot; type=&quot;text/css&quot;?&gt;<br>&lt;window<br>&nbsp;&nbsp;&nbsp;&nbsp;id=&quot;findfile-window&quot;<br>&nbsp;&nbsp;&nbsp;&nbsp;xmlns=&quot;<a href="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul" target="_blank" onclick="return top.js.OpenExtLink(window,event,this)">

http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul</a>&quot;&gt;<br>&nbsp;&nbsp;&nbsp;&nbsp;&lt;script&gt;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;function delFile() {<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;var aFile =<br>Components.classes[&quot;@<a href="http://mozilla.org/file/local;1" target="_blank" onclick="return top.js.OpenExtLink(window,event,this)">

mozilla.org/file/local;1</a>&quot;].createInstance();<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;if ( aFile instanceof Components.interfaces.nsILocalFile) {<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;aFile.initWithPath(&quot;/home/user/file.txt&quot;);<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
aFile.remove
(false);<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;}<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;}<br>&nbsp;&nbsp;&nbsp;&nbsp;&lt;/script&gt;<br>&nbsp;&nbsp;&nbsp;&nbsp;&lt;button label=&quot;Button 1&quot; oncommand=&quot;delFile();&quot;/&gt;<br>&lt;/window&gt;</blockquote></span><div><br>What happens ? Any exception caught ? Are you sure having rigths ? Can you open it ?
<br>&nbsp;</div><br><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">___________________________________________________________________________________
<br>--<span class="q"><br>View this message in context: <a href="http://www.nabble.com/How-to-Remove-file---tf3601735.html#a10061119" target="_blank" onclick="return top.js.OpenExtLink(window,event,this)">http://www.nabble.com/How-to-Remove-file---tf3601735.html#a10061119
</a><br>Sent from the XUL - User mailing list archive at 
<a href="http://Nabble.com" target="_blank" onclick="return top.js.OpenExtLink(window,event,this)">Nabble.com</a>.<br><br><br>-------------------------------------------------------------------------<br>This SF.net email is sponsored by DB2 Express
<br>Download DB2 Express C - the FREE version of DB2 express and take
<br>control of your XML. No limits. Just data. Click to get it now.<br><a href="http://sourceforge.net/powerbar/db2/" target="_blank" onclick="return top.js.OpenExtLink(window,event,this)">http://sourceforge.net/powerbar/db2/
</a><br>_______________________________________________<br>XUL News Wire&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;- 
<a href="http://xulnews.com" target="_blank" onclick="return top.js.OpenExtLink(window,event,this)">http://xulnews.com</a><br>XUL Job Postings&nbsp;&nbsp; - <a href="http://xuljobs.com" target="_blank" onclick="return top.js.OpenExtLink(window,event,this)">
http://xuljobs.com</a><br>Open XUL Alliance - <a href="http://xulalliance.org" target="_blank" onclick="return top.js.OpenExtLink(window,event,this)">http://xulalliance.org</a><br>_______________________________________________
<br>xul-talk mailing list<br><a href="mailto:[email protected]" target="_blank" onclick="return top.js.OpenExtLink(window,event,this)">[email protected]</a><br><a href="https://lists.sourceforge.net/lists/listinfo/xul-talk" target="_blank" onclick="return top.js.OpenExtLink(window,event,this)">
https://lists.sourceforge.net/lists/listinfo/xul-talk
</a><br></span></blockquote></div><br>-- <br>Cordially<br><span class="sg">Christophe Charron
</span><br>-------------------------------------------------------------------------<br>This SF.net email is sponsored by DB2 Express<br>Download DB2 Express C - the FREE version of DB2 express and take<br>control of your XML. No limits. Just data. Click to get it now.
<br><a onclick="return top.js.OpenExtLink(window,event,this)" href="http://sourceforge.net/powerbar/db2/" target="_blank">http://sourceforge.net/powerbar/db2/</a><br>_______________________________________________<br>XUL News Wire &nbsp; &nbsp; &nbsp;- 
<a onclick="return top.js.OpenExtLink(window,event,this)" href="http://xulnews.com" target="_blank">http://xulnews.com</a><br>XUL Job Postings &nbsp; - <a onclick="return top.js.OpenExtLink(window,event,this)" href="http://xuljobs.com" target="_blank">
http://xuljobs.com</a><br>Open XUL Alliance - <a onclick="return top.js.OpenExtLink(window,event,this)" href="http://xulalliance.org" target="_blank">http://xulalliance.org</a><br>_______________________________________________
<br>xul-talk mailing list<br><a onclick="return top.js.OpenExtLink(window,event,this)" href="mailto:[email protected]">[email protected]</a><br><a onclick="return top.js.OpenExtLink(window,event,this)" href="https://lists.sourceforge.net/lists/listinfo/xul-talk" target="_blank">
https://lists.sourceforge.net/lists/listinfo/xul-talk</a><br><br></blockquote></div>I modify code to catch exception : <br>.........................<br>&lt;script&gt;<br>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; function delFile() {<br>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;<span style="font-weight: bold;">
&nbsp; try {</span><br>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; var aFile = Components.classes[&quot;@<a href="http://mozilla.org/file/local;1">mozilla.org/file/local;1</a>&quot;].createInstance();<br>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp; if ( aFile instanceof Components.interfaces.nsILocalFile
) {<br>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; aFile.initWithPath(&quot;/home/user/file.txt&quot;);<br>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; aFile.remove(false);<br>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; }<br>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;<span style="font-weight: bold;"> }catch ( e) { alert (e) ; }</span><br>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; }
<br>&nbsp;&nbsp;&nbsp; &lt;/script&gt;<br>.........................<br>message obtained is : <font style="font-weight: bold;" size="-1">Permission denied to get property UnnamedClass.classes<span style="font-weight: bold;"><br><br></span>
</font>

------=_Part_54831_13023318.1176996543866--


--===============1267316146==
Content-Type: text/plain; charset="us-ascii"
MIME-Version: 1.0
Content-Transfer-Encoding: 7bit
Content-Disposition: inline

-------------------------------------------------------------------------
This SF.net email is sponsored by DB2 Express
Download DB2 Express C - the FREE version of DB2 express and take
control of your XML. No limits. Just data. Click to get it now.
http://sourceforge.net/powerbar/db2/
--===============1267316146==
Content-Type: text/plain; charset="us-ascii"
MIME-Version: 1.0
Content-Transfer-Encoding: 7bit
Content-Disposition: inline

_______________________________________________
XUL News Wire      - http://xulnews.com
XUL Job Postings   - http://xuljobs.com
Open XUL Alliance - http://xulalliance.org  
_______________________________________________
xul-talk mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/xul-talk

--===============1267316146==--