View Full Version : to eliminate archives from the PC, the multiple selection in listbox
Solmos
01-07-2007, 01:05 PM
like eliminating archives in the PC from or several items selected in listbox?
for example,
the items of my listbox:
C:\ss.txt
C:\jj.txt
D:\vv.txt
the 3 items selected in listbox, like making simultaneously to eliminate them of the PC the 3?
and like doing that, for example, if item 1 fails the eliminated being, one does not erase of the list of items of listbox, but if it is eliminated correctly of the PC, that is also eliminated of the list of listbox
thank you very much!
bobbie
01-07-2007, 03:07 PM
Have a look at Samples by Azmanar he has some listboxs that might help you.
http://www.azman.info/ams/
Solmos
01-07-2007, 03:49 PM
thanks but in no of those example put what I look for aid please!
RizlaUK
01-08-2007, 07:02 AM
ok, there is a great example of almost what you need in the ams manual, im sure with a little bit of editing you will achive your goal
-- Gets the path to the user's My Documents folder.
my_docs_path = Shell.GetFolder(SHF_MYDOCUMENTS);
-- Check to see if the My Documents folder detection was successful.
if (Application.GetLastError() == 0)then
-- Search the user's My Documents folder for the file "Data.ini".
search_results = File.Find(my_docs_path, "Data.ini", true, false, nil);
--Check to see if an error occurred during the search. If it did, display the error message.
error = Application.GetLastError();
if error ~= 0 then
Dialog.Message("Error",_tblErrorMessages[error]);
else
-- If no files were found, notify the user.
if (search_results == nil) then
Dialog.Message("Notice", "Data.ini was not found in your My Documents folder.");
-- If files were found, display a dialog containing a list of their locations.
-- Also ask for deletion confirmation.
else
message = "Data.ini was found in the following location(s). Click OK to delete the file(s):\r\n\r\n";
for index, path in search_results do
message = String.Concat(message, path.."\r\n");
end
proceed = Dialog.Message("File Search Results", message, MB_OKCANCEL, MB_ICONQUESTION, MB_DEFBUTTON1);
-- If the user clicked OK, delete all of the files found.
if proceed == IDOK then
-- Delete each file found in the search.
for index, path in search_results do
File.Delete(path, false, false, false, nil);
-- Check to see if any errors occurred during the deletion.
if (Application.GetLastError() ~= 0) then
Dialog.Message("Error", "The file located at: "..path.." could not be deleted.");
end
end
end
end
end
end
This example uses the File.Find action to search for all copies of a particular INI file in the user's My Documents folder. If the file is found in more than one location, the user is presented with the list and asked if they wish to delete them. If they agree, each copy is deleted using the File.Delete action.
Solmos
01-08-2007, 09:55 AM
thanks,
it works well
but I need that I eliminate the present archives in listbox, and if she eliminates it correctly that also she eliminates the text of listbox.
for example, this listbox is the content of my:
C:\Documents and seting\xx.txt
D:\mydocument.txt
D:\Temp\temp.txt
if the user selects the three items (in listbox, with the activated multiselection), that the selected items are eliminated of the PC, and if they are eliminated correctly, tam, is eliminated well of listbox.
thanks!
Solmos
01-11-2007, 05:39 PM
please help!
RizlaUK
01-11-2007, 06:19 PM
then you just need to add a "ListBox.DeleteItem" in with your "File.Delete"
attach the apz for what you have now and i'll see if i can come up with something, but not knowing how you have coded your app i cant realy help,
you could try something like this
this will delete the selected item a listbox and the file wich path is in the selected items data
sel = ListBox.GetSelected("ListBox1");
if sel then
LBData = ListBox.GetItemData("ListBox1", sel[1]);
File.Delete(LBData, false, false, false, nil);
ListBox.DeleteItem("ListBox1", sel[1]);
end
but its very short and crude and no error checking
Solmos
01-12-2007, 02:57 PM
thank you very much,
problem I am using your scrip, I have modified it a little, and added some things and now it works perfectly.
thanks!
RizlaUK
01-12-2007, 03:03 PM
Hey no problem, glad you got it in the end ;)
vBulletin® v3.8.4, Copyright ©2000-2009, Jelsoft Enterprises Ltd.