Hi, I have a dialog box and basically I have set it so that the user can select multiple file. When it is set to just select 1 file I can get the string for the path of the file by

AnsiString LinkPath =  (OpenDialog1->FileName);

However when I want to retrieve the names of all of the files selected by the user, the above method only provides me with the last one highlighted by the user before they press select hence I miss out on other files if there are multiple files in the selection.

I was just wondering if anyone had come across this problem before and could possibly advise how they solved it?

after a quick bit of googling I can across the below bit of code which seems to be everything I'm looking for but For some reasons I get errors with cannot convert ansistring to const char#

char buf[_MAX_PATH + 1];

    char *p = OpenDialog1->FileName + strlen(OpenDialog1->FileName) + 1;

    do
    {
      strcpy(buf, OpenDialog1->FileName);
      if (*p)   // The case of multiple file selection
      {
        strcat(buf, "\\");
        strcat(buf, p);
      }

      // Process the file
      MessageBox(buf);

      // go to next file name
      if (*p)
        p = p + strlen(p) + 1;

    } while (*p);

If anyone knows of a better way I would love to hear about it!

thank you

Isn't there a Files property (which should be a TStringList or somesuch)?

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.