Jump to content
Fórum Script Brasil
  • 0

Excluir Arquivos


OSJunior

Question

Opa! Salve galera!

Faz um tempinho que num aparecia por aqui.

Minha dúvida: Como ao clicar num button, exclua arquivos e até mesmo pastas.

Mas escolhendo num Edit, a pasta que o user deseja excluir.

//Abraços pro Kiko e pro Progr'amador

falou.

Link to comment
Share on other sites

3 answers to this question

Recommended Posts

  • 0

Olá OSJunior,

//Abraços pro Kiko e pro Progr'amador

Ae valeu pela força!! biggrin.gif

Ae testa essa função

function DeleteFolder(FolderName: String; LeaveFolder: Boolean): Boolean;
var
  r: TshFileOpStruct;
begin
  Result := False;
  if not DirectoryExists(FolderName) then
  Exit;
  if LeaveFolder then
  FolderName := FolderName + ' *.* '
  else
  if FolderName[Length(FolderName)] = ' \ ' then
  Delete(FolderName,Length(FolderName), 1);
  FillChar(r, SizeOf(r), 0);
  r.wFunc := FO_DELETE;
  r.pFrom := PChar(FolderName);
  r.fFlags := FOF_ALLOWUNDO or FOF_NOCONFIRMATION;
  Result := ((ShFileOperation(r) = 0) and (not r.fAnyOperationsAborted));
end;
Usa-se assim
deleteFolder('c:\temp',false);
No caso você colocaria deleteFolder(Edit1.text,false); Para apagar um arquivo
if FileExists('C:\MEUDIR\MEUARQ.DAT') then DeleteFile('C:\MEUDIR\MEUARQ.DAT');

Abs.

Kiko

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Answer this question...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.



  • Forum Statistics

    • Total Topics
      152.2k
    • Total Posts
      651.8k
×
×
  • Create New...