ورود

View Full Version : پاک کردن پوشه از پاک کردن پوشه از shelllistview



hadiaj168
یک شنبه 26 مهر 1388, 16:06 عصر
با سلام
من یه shelllistview دارم که با کد زیر یه پوشه خالی رو از توش انتخاب و بعد پاک میکنم:


function Tform1.SelectedFiles(AShellView: TShellListView): TStringList;
var
i : integer;
begin
Result := TStringList.Create;
for i := 0 to shelllistview1.Items.Count - 1 do
// is the item selected?
if shelllistview1.Items[i].Selected = True then
// Folders can also refer to files, which is why we check isFolder
// before adding the filepath to the result
//**if shelllistview1.folders[i].IsFolder = False then
// add filepath and filename to result
Result.Add(shelllistview1.Folders[i].PathName);

end;

procedure TForm1.Button2Click(Sender: TObject);
var
i: Integer;
SelectedFileList: TStringList;
//t: Integer;
//T : MyThread;
begin
try
SelectedFileList := TStringList.Create; //create stringlist to contain filenames
SelectedFileList := SelectedFiles(ShellListView1); //populate tstringlist

if SelectedFileList.Count = 0 then Exit; //exit if no files selected

RmDir(SelectedFileList[0]);

finally
FreeAndNil(SelectedFileList); //free tstringlist when finished
end;
end;


حالا اگه یک بار وارد پوشه بشم و بعد با shelllistview1.Back خارج بشم پوشه مورد نظر تا خروج از برنامه پاک نمیشه اما همین که برنامه بسته بشه پاک میشه! چرا و چگونه؟

hadiaj168
دوشنبه 27 مهر 1388, 01:20 صبح
البته فقط زمانی که اتو رفرش ترو باشه این اتفاق می افته.
یه سوال دیگه:
DeleteSelected چی کار میکنه ؟