Como criar pastas no windows via código?

Delphi

01/02/2008

Procurei no fórum mas tá muito difícil de encontrar... preciso criar pastas no windows via programação... alguém pode me ajudar?


Janete

Janete

Curtidas 0

Respostas

Fabiano Góes

Fabiano Góes

01/02/2008

um exemplo:

   if not DirectoryExists(´c:\Temp\´) then
   begin
      ForceDirectories(´c:\Temp\´);
   end;



GOSTEI 0
Pestana_

Pestana_

01/02/2008

um outro exemplo retirado do help do Delphi:

The following example creates a directory ‘C:\temp’ if it does not already exist. uses FileCtrl; procedure TForm1.Button1Click(Sender: TObject); begin if not DirectoryExists(´c:\temp´) then if not CreateDir(´C:\temp´) then raise Exception.Create(´Cannot create c:\temp´); end;



flw.


GOSTEI 0
Paullsoftware

Paullsoftware

01/02/2008

um outro exemplo retirado do help do Delphi: [quote:a5916643c2]The following example creates a directory ‘C:\temp’ if it does not already exist. uses FileCtrl; procedure TForm1.Button1Click(Sender: TObject); begin if not DirectoryExists(´c:\temp´) then if not CreateDir(´C:\temp´) then raise Exception.Create(´Cannot create c:\temp´); end;



flw.[/quote:a5916643c2]
Acho a dica do Fábio melhor, pois, se você quiser criar uma SubPasta ele cria diretamente sem precisar criar um diretorio antes o que acontece com o CreateDir...


GOSTEI 0
Warfighter

Warfighter

01/02/2008

Modo mais simples


procedure TForm1.Button1Click(Sender: TObject);
begin
[color=red][b:ba0c2e2be8]CreateDir(´C:\Sua_Pasta´);[/[/b:ba0c2e2be8]color]
end;


Até +


GOSTEI 0
Warfighter

Warfighter

01/02/2008

procedure TForm1.Button1Click(Sender: TObject);
begin
CreateDir(´C:\Sua_Pasta´);
end;

saiu errado :roll:

flw


GOSTEI 0
POSTAR