Escondendo I/O error ..

Delphi

08/12/2003

Boa Noite Galera, bom tenho um [b:b7cd57a32b]DirectoryListBox[/b:b7cd57a32b] e um [b:b7cd57a32b]filelistbox[/b:b7cd57a32b] tenho um botao que ao clicar executa a funcao abaixo:

RemotoDirectoryListBox.drive := ´c´; // Pega drive C:
RemotoDirectoryListBox.Directory := ´\\´+remotoip.Text+´\c´; // Neste IP
RemotoFileListBox.Drive := RemotoDirectoryListBox.Drive; //Lista arquivos deste diretorio

Bom até ae funciona mas quero saber quando ele não encontrar o caminho ? Ele mostra uma mensagem de I/O error que fica feio gostaria de saber como eu faço uma função que ele identifica que deu erro ou nao achou a maquina que eu mandei procurar na rede e manda uma mensagem padrao designada por mim ?


valeu

:D
koringa


Koringa

Koringa

Curtidas 0

Respostas

Beppe

Beppe

08/12/2003

Coloca seu código num try/except:

try
  RemotoDirectoryListBox.drive := ´c´; // Pega drive C: 
  RemotoDirectoryListBox.Directory := ´\\´+remotoip.Text+´\c´; // Neste IP 
  RemotoFileListBox.Drive := RemotoDirectoryListBox.Drive; //Lista arquivos deste diretorio 
except
  ShowMessage(´Um erro ocorreu´);
end;



GOSTEI 0
Maicongabriel

Maicongabriel

08/12/2003

ou ainda...

try 
  RemotoDirectoryListBox.drive := ´c´; // Pega drive C: 
  RemotoDirectoryListBox.Directory := ´\\´+remotoip.Text+´\c´; // Neste IP 
  if DirectoryExists(RemotoDirectoryListBox.Directory) then
    RemotoFileListBox.Drive := RemotoDirectoryListBox.Drive //Lista arquivos deste diretorio 
  else ShowMessage(´O Diretorio não existe´);
except 
  ShowMessage(´Um erro ocorreu´); 
end;



GOSTEI 0
POSTAR