Delete a folder |
Author: |
Message: |
Lamaboy
New Member
Posts: 4
Joined: Jan 2011
|
O.P. Delete a folder
I've found this:
code: File.DeleteFile(File);
but I need to do it for an entire folder, how can I do this?
Thanks.
This post was edited on 01-19-2011 at 05:33 AM by Lamaboy.
|
|
01-19-2011 05:30 AM |
|
|
Spunky
Former Super Mod
Posts: 3658 Reputation: 61
36 / /
Joined: Aug 2006
|
RE: Delete a folder
I think the folder needs to be empty first anyway...
It should just be
code: File.DeleteFolder(Folder);
Can't remember if Folder is a folder object or a string identifying it though... Just search for 'MSDN DeleteFolder' in Google
<Eljay> "Problems encountered: shit blew up"
|
|
01-19-2011 06:35 AM |
|
|
gmr
New Member
Posts: 2
– / /
Joined: Jan 2011
|
RE: Delete a folder
"File" must be a FileSystemObject.
It looks just like this:
code: var File = new ActiveXObject("Scripting.FileSystemObject");
File.DeleteFolder("FolderNameToDeleteAsString");
Further information:
MSDN - DeleteFolder Method
quote: Originally posted by Spunky
I think the folder needs to be empty first anyway...
No, see Remarks on the link above.
|
|
01-20-2011 12:14 AM |
|
|
Lamaboy
New Member
Posts: 4
Joined: Jan 2011
|
O.P. RE: Delete a folder
Thanks, it works, but not quite.
code: Error: Permission denied (code: -2146828218)
The folder is read only, so how else can I keep one specific window from recording chat logs?
This post was edited on 01-20-2011 at 02:33 AM by Lamaboy.
|
|
01-20-2011 12:58 AM |
|
|
Spunky
Former Super Mod
Posts: 3658 Reputation: 61
36 / /
Joined: Aug 2006
|
RE: Delete a folder
quote: Originally posted by gmr
quote: Originally posted by Spunky
I think the folder needs to be empty first anyway...
No, see Remarks on the link above.
I may have been thinking about PHP then.
As for the permission thing, can you not change ownership of the folder or at least give yourself write permissions?
<Eljay> "Problems encountered: shit blew up"
|
|
01-20-2011 06:23 AM |
|
|
CookieRevised
Elite Member
Posts: 15517 Reputation: 173
– / /
Joined: Jul 2003
Status: Away
|
RE: Delete a folder
quote: Originally posted by Lamaboy
Thanks, it works, but not quite.
code: Error: Permission denied (code: -2146828218)
The folder is read only, so how else can I keep one specific window from recording chat logs?
Can you explain in detail what you're trying to do? Can you show all the code you have?
Because like it sounds now, you're trying to do something which you shouldn't be doing in the way you're doing it.
(Constantly removing a folder to prevent a certain chat log from being created is a very very bad way of doing things. And if that is what you're trying to do then the reason for the error is that you can not remove something which is locked and used by another program for writing stuff to it. Thus instead of trying to remove the logs (which you will not be able to do properly anyways) you should disable the chat logging itself.)
This post was edited on 01-20-2011 at 07:44 PM by CookieRevised.
.-= A 'frrrrrrrituurrr' for Wacky =-.
|
|
01-20-2011 09:41 AM |
|
|
gmr
New Member
Posts: 2
– / /
Joined: Jan 2011
|
RE: RE: Delete a folder
quote: Originally posted by Lamaboy
Thanks, it works, but not quite.
code: Error: Permission denied (code: -2146828218)
The folder is read only, so how else can I keep one specific window from recording chat logs?
I have no folder to test it under your circumstances right now if this works but have you tried to set the force parameter in the DeleteFolder Method described on the link I mentioned?
If yes, maybe there is a WinAPI function to unlock the folder first?
Well, I know there is one, but I'm not quite sure how you do it within JavaScript. And even if you can unlock it, you may run into other problems later.
However, CookieRevised is right, deleting a folder that is used several times and locked for that shouldn't be deleted as it may lead to serious problems up to crashing the program (not WLM specific but who knows?^^).
So, as CookieRevised said as well: more information may help us to help you.
|
|
01-20-2011 05:55 PM |
|
|
matty
Scripting Guru
Posts: 8336 Reputation: 109
39 / /
Joined: Dec 2002
Status: Away
|
RE: Delete a folder
quote: Originally posted by Lamaboy
The folder is read only, so how else can I keep one specific window from recording chat logs?
In the Plus! menu on the conversation window you can disable chat logging can you not? If so just and it keeps enabling after you reopen the chat window write a script that clicks the menu item.
This post was edited on 01-20-2011 at 06:00 PM by matty.
|
|
01-20-2011 05:59 PM |
|
|
Lamaboy
New Member
Posts: 4
Joined: Jan 2011
|
O.P. RE: Delete a folder
I'll post my code, but you'll plainly see that I borrowed the entire first chunk of it from the usay script.
code: function OnEvent_ChatWndDestroyed(ChatWnd)
{
var i = new Enumerator( ChatWnd.Contacts );
var thedude;
switch( ChatWnd.Contacts.Count )
{
case 1:
thedude = i.item();
break;
//we dont really get here in real life
case 0:
//talking to myself again?
helpstring = "It seems like nobody wants to talk to you\n\rAre you talking to yourself again?";
Interop.Call("User32.dll", "MessageBoxW", 0, helpstring, "USay - Error", 0);
abort = true;
break;
default:
//gangbang mode
var contact_email = GetContactEmail( Command[j], ChatWnd.Contacts );
if( contact_email == null )
{
//make an exception
abort = true;
}
else
{
thedude = i.item();
while( !i.atEnd() && i.item().Email != contact_email )
{
i.moveNext();
}
j++;
}
}
var contact_email = thedude.email
if ( contact_email == "email@email.com" )
{
Interop.Call("User32.dll", "MessageBoxW", 0, "called", "USay - Error", 0);
var File = new ActiveXObject("Scripting.FileSystemObject");
File.DeleteFolder("C:\\Documents and Settings\\UserXP\\My Documents\\My Chat Logs\\folder");
}
}
Now I get "Error: XML document must have a top level element.
(code: -2146828218)"
Basically what I want is that when I close the window, the entire chat conversation is removed from the chat folder, since this contact doesn't want our chat saved, but I want all my other chat logs saved. If someone has a better way to do it, please let me know. Thanks.
|
|
01-20-2011 11:25 PM |
|
|
prashker
Veteran Member
Posts: 5109 Reputation: 104
– / / –
Joined: Mar 2005
Status: Away
|
RE: Delete a folder
Why delete it when you can just disable it from logging (FOR THAT CONTACT)
this is some pseudocode, but the important functions are real
OnEvent_ChatWndCreated(ChatWnd) {
var contact = <whatever to get email>
if contact == "email@email.com" do:
The ChatWnd::ChatLogEnabled property sets or gets the "Logging" option of the chat window. This affects whether or not Messenger Plus! saves the content of the chat in a log file. This does not affect Messenger's own XML logs.
}
Set it to false, and it'll go back to true once you close the window.
Also, if the window is closed and re-opened, the property is set back to its original value based on the user's preferences.
This post was edited on 01-21-2011 at 01:43 AM by prashker.
|
|
01-21-2011 01:40 AM |
|
|
Pages: (2):
« First
[ 1 ]
2
»
Last »
|
|