BCB6 w/Indy 9: Uploading Directories

Giganews Newsgroups
Subject: BCB6 w/Indy 9: Uploading Directories
Posted by:  poojo hackma (poojo.com/mail)
Date: Tue, 10 Jan 2006

I need to upload a list of files, directories, and all the files and
subdirectories that are contained.

How do I verify that a directory exists?

//-----------------------------------------------------
AnsiString aDirName;
indy->MakeDir(aDirName); // creates a new directory
indy->ChangeDir(aDirName); // changes to that directory
aDirName = indy->RetrieveCurrentDir; // tells me where I am
//-----------------------------------------------------

Is there a way to check for the existence of a directory, or do I have to go
round and round with the three commands above?

This is the only way I can think to get around this:

//-----------------------------------------------------
AnsiString aDirName;
AnsiString aTestDir;
indy->ChangeDir(aDirName);
aTestDir = indy->RetrieveCurrentDir;
if (aTestDir != aDirName)
{
  indy->MakeDir(aDirName);
  indy->ChangeDir(aDirName);
  aTestDir = indy->RetrieveCurrentDir;
  if (aTestDir != aDirName)
  {
    // return an error;
  }
}
//-----------------------------------------------------

That is ugly.

Replies