locked
How to process all files in folder RRS feed

  • Question

  • I am new to visual studio/ Managed C++. I don't know even in which category MSDN or Managed C++ comes in. I hope i have selected right options from 'forum category' and 'Forum'

    My Question is - I want to select and process all images present in folder, if user selects a 'checkbox' named "All". 
    Name of images may or may not be same.

    Till now, Got file path by => System String^ imgPath = objFileDialog->FileName;
    &  folder path by => System String^ folderPath = System::IO::Path::GetDirectoryName(imgPath); 

    Please help me.


    • Edited by Dipak000 Tuesday, October 28, 2014 11:40 AM
    Tuesday, October 28, 2014 11:38 AM

Answers

  • This fragment enumerates all of the files:

    for each ( FileInfo ^ f in DirectoryInfo( folderPath ).EnumerateFiles() )
    {
           String ^ filePath = f->FullName;
    
           // . . .
    }

    In order to enumerate files having a particular extension, see other variants of EnumerateFiles. To extract the name or extension, see FileInfo or System::IO::Path.



    • Edited by Viorel_MVP Tuesday, October 28, 2014 12:02 PM
    • Proposed as answer by Fred Bao Wednesday, October 29, 2014 1:57 AM
    • Marked as answer by Dipak000 Wednesday, October 29, 2014 10:51 AM
    Tuesday, October 28, 2014 12:01 PM

All replies

  • This fragment enumerates all of the files:

    for each ( FileInfo ^ f in DirectoryInfo( folderPath ).EnumerateFiles() )
    {
           String ^ filePath = f->FullName;
    
           // . . .
    }

    In order to enumerate files having a particular extension, see other variants of EnumerateFiles. To extract the name or extension, see FileInfo or System::IO::Path.



    • Edited by Viorel_MVP Tuesday, October 28, 2014 12:02 PM
    • Proposed as answer by Fred Bao Wednesday, October 29, 2014 1:57 AM
    • Marked as answer by Dipak000 Wednesday, October 29, 2014 10:51 AM
    Tuesday, October 28, 2014 12:01 PM
  • Hello Dipak000,

    This forum VC++ is used to discuss and ask questions about the Visual C++.

    Regards.


    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click HERE to participate the survey.

    Wednesday, October 29, 2014 1:58 AM