quarta-feira, 11 de agosto de 2010

Algumas dicas Uteis

Apagar arquivos via MS-DOS:

WinExec('Command.com /c Del c:\temp\*.tmp', 0)
-----------------------------------------------------------------------------------

Como extrair o tamanho de um arquivo:

function TForm1.TamArquivo(Arquivo: string): Integer;
begin
with TFileStream.Create(Arquivo, fmOpenRead or fmShareExclusive) do
try
Result := Size;
finally
Free;
end;
end;

Utilize a função assim:

procedure TForm1.Button1Click(Sender: TObject);
begin
edit1.text:= inttostr(TamArquivo('CAMINHO\NOMEDOARQUIVO'));
end;
-----------------------------------------------------------------------------------

Como verificar se um arquivo existe:

If not(fileexists('c:\windows\nuvens.bmp')) then Showmessage('Arquivo inexistente');

-----------------------------------------------------------------------------------

Copiando arquivos:

Função: CopyFile('Origem','Destino',True);
Exemplo: CopyFile('c:\logo.sys','c:\logo.bmp',True)
True : Instrui para sobrescrever o arquivo destino (caso encontre)

Nenhum comentário:

Postar um comentário