[vtkusers] Problem with reading files

David Doria daviddoria+vtk at gmail.com
Fri Aug 6 11:17:26 EDT 2010


On Fri, Aug 6, 2010 at 11:06 AM, Bill Lorensen <bill.lorensen at gmail.com> wrote:
> Take a look at this example:
> http://vtk.org/Wiki/VTK/Examples/Utilities/DirectoryFileExtensions
>
> It is similar to your code. but it constructs a full pathname from the
> directory and file name.
>
> Bill

Your code works fine for me (Fedora). Are you calling the program with:

./TestProgram Directory

or some other argument?

What operating system are you using?

Try hard coding a directory:

#include <vtkSmartPointer.h>
#include <vtkDirectory.h>

#include <vtksys/SystemTools.hxx>

int main(int, char *[])
{

  vtkstd::string inputDirectory = ".";
  vtkSmartPointer<vtkDirectory> directory =
    vtkSmartPointer<vtkDirectory>::New();

  int opened = directory->Open(inputDirectory.c_str());

  if(opened)
   {

    int numImages = directory->GetNumberOfFiles();

    for (int i = 0; i < numImages; i++)
      {
      vtkstd::string filename = directory->GetFile(i);
      vtkstd::string ext =
        vtksys::SystemTools::GetFilenameLastExtension(filename);

      }
    }
}

Thanks,

David



More information about the vtkusers mailing list