Fórum funcão para criação de novos diretórios #264469
06/01/2005
0
[color=red:4184c73748][/color:4184c73748][size=18:4184c73748][/size:4184c73748]olá gostaria de saber se alguem conhece alguma função para criar novos diretorios... e aproveitando tb eu estava precisando de uma funcao que retorne o tamanho do diretorio (para ser utilizada em uma progressbar).
vlw
vlw
Greghowe
Curtir tópico
+ 0
Responder
Posts
06/01/2005
Vprates
Segue um exemplo de como criar um diretorio
var
Dir: string;
begin
Dir := ´C:\temp\teste´;
if not DirectoryExists(Dir) then
ForceDirectories(Dir);
Label1.Caption := Dir + ´ foi criado´;
end;
Ve se eh isso q tu precisa
var
Dir: string;
begin
Dir := ´C:\temp\teste´;
if not DirectoryExists(Dir) then
ForceDirectories(Dir);
Label1.Caption := Dir + ´ foi criado´;
end;
Ve se eh isso q tu precisa
Responder
Gostei + 0
06/01/2005
Vprates
function GetDirectorySize(const ADirectory: string): Integer;
var
Dir: TSearchRec;
Ret: integer;
Path: string;
begin
Result := 0;
Path := ExtractFilePath(ADirectory);
Ret := Sysutils.FindFirst(ADirectory, faAnyFile, Dir);
if Ret NO_ERROR then
exit;
try
while ret=NO_ERROR do
begin
inc(Result, Dir.Size);
if (Dir.Attr in [faDirectory]) and (Dir.Name[1] ´.´) then
Inc(Result, GetDirectorySize(Path + Dir.Name + ´*.*´));
Ret := Sysutils.FindNext(Dir);
end;
finally
Sysutils.FindClose(Dir);
end;
end;
Procedure Bitbtn1Onclick(Sender : TObject);
begin
Caption:=IntToStr( GetDirectorySize(´c:\temp\teste´) );
end;
Essa função eu não testei.
var
Dir: TSearchRec;
Ret: integer;
Path: string;
begin
Result := 0;
Path := ExtractFilePath(ADirectory);
Ret := Sysutils.FindFirst(ADirectory, faAnyFile, Dir);
if Ret NO_ERROR then
exit;
try
while ret=NO_ERROR do
begin
inc(Result, Dir.Size);
if (Dir.Attr in [faDirectory]) and (Dir.Name[1] ´.´) then
Inc(Result, GetDirectorySize(Path + Dir.Name + ´*.*´));
Ret := Sysutils.FindNext(Dir);
end;
finally
Sysutils.FindClose(Dir);
end;
end;
Procedure Bitbtn1Onclick(Sender : TObject);
begin
Caption:=IntToStr( GetDirectorySize(´c:\temp\teste´) );
end;
Essa função eu não testei.
Responder
Gostei + 0
Clique aqui para fazer login e interagir na Comunidade :)