GARANTIR DESCONTO

Fórum Cria sub pastas no delphi #176034

19/08/2003

0

Oi galera estou com um problema, preciso criar uma rotina que cria diretorios e subdiretorio, acontece que o comando

´createdir(´C:\casa\MinhaPasta´);´

nao funciona quando colocamos subdiretorios, so funciona quando colocamos do o diretorio princial

´createdir(´C:\casa´);´

que sober uma soluçao vou ficar grato


Tuca100

Tuca100

Responder

Posts

19/08/2003

Joilson_gouveia

Use o help...

This example uses a label and a button on a form. When the user clicks the button, all the directories along the specified path that don´t exist are created. The results are reported in the caption of the label:

procedure TForm1.Button1Click(Sender: TObject);

var
Dir: string;
begin

Dir := ´C:\APPS\SALES\LOCAL´;

if DirectoryExists(Dir) then
Label1.Caption := Dir + ´ was created´

end;


Responder

Gostei + 0

20/08/2003

Keliniciante

// Declare FileCtrl na seção USES.
function MkSubDir(sPath : string): Boolean;
begin
if(´\´ = sPath[Length(sPath)])then
begin
sPath := Copy(sPath, 1,Length(sPath)-1);
end;
if((Length(sPath) < 3) or FileCtrl.DirectoryExists(sPath))then
begin
Exit; end;
MkDirMulti(SysUtils.ExtractFilePath(sPath));
try
System.MkDir( sPath );
Result := true;
except
Result := False;
end; end;


Responder

Gostei + 0

20/08/2003

Keliniciante

Para criar um diretório você precisa usar a função ForceDirectories, o exemplo a baixo testa se não existe um diretório e cria o diretório apartir de uma variável string testando se o diretório já existe
Unit
FileCtrl
procedure TForm1.Button1Click(Sender: TObject);
var
Dir: string;
begin
Dir := ´C:\APPS\SALES\LOCAL´;
if not DirectoryExists(Dir) then
ForceDirectories(Dir);
Label1.Caption := Dir + ´ foi criado´;
end;


Responder

Gostei + 0

20/08/2003

Bacalhau

Eeeeena que complicação. Arranjando problemas para cada solução! eheheheh

Tenta:

Mkdir(´c:\casa´); // pasta principal
CHDir(´Casa´); // colocas-te na pasta criada
MkDir(´OutraPasta´) // já está!!

Abraço do bacalhau


Responder

Gostei + 0

Utilizamos cookies para fornecer uma melhor experiência para nossos usuários, consulte nossa política de privacidade.

Aceitar