Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Categories

How to filter specific files from a drive or folder

JayalakshmiJayalakshmi Member Posts: 14
Hi
I want to filter files with exn JPEG from user selected drive say C:,D: etc.. or from a userselected folder in the drive say C:Images etc.How to do this?
Mean time I want to create a folder in userselected drive say C:,D: etc and write specific files
say fileinfo.ixx in the folder create.How to do this?

Thanks in advance
Jayalakshmi

Comments

  • DB1DB1 Member Posts: 1,142
    : Hi
    : I want to filter files with exn JPEG from user selected drive say C:,D: etc.. or from a userselected folder in the drive say C:Images etc.How to do this?
    : Mean time I want to create a folder in userselected drive say C:,D: etc and write specific files
    : say fileinfo.ixx in the folder create.How to do this?
    :
    : Thanks in advance
    : Jayalakshmi
    :

    You can use FindFirstFile(...) along with FindNextFile(...) and filter out any thing you want with a strcmp statement.
    [code]
    HANDLE dir;
    WIN32_FIND_DATA fd;
    CString fName;
    dir = FindFirstFile( "*.*", &fd );

    if( dir == NULL ) return;

    while ( 1 )
    {
    // search for files only
    if( !(fd.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY) )
    {
    // get the filename
    fName = fd.cFileName;

    // filter out jpegs
    if ( (fName.Find(".jpg", 0) == -1 && fName.Find(".jpeg", 0) == -1) )

    // write the filtered list to file
    MyWriteFunction(fName);
    }
    if( !FindNextFile( dir, &fd ) )
    {
    break;
    }
    }
    FindClose( dir );
    [/code]
  • Andre YoungAndre Young USAMember Posts: 0

    _____ { http://forcoder.org } free video tutorials and ebooks about / Perl Java JavaScript Swift Assembly Ruby Scratch R Objective-C PHP Python C Delphi MATLAB Visual Basic .NET Go Visual Basic C# PL/SQL C++ Awk Fortran Clojure Scheme Erlang VBScript F# Logo Apex Hack Rust Lisp Lua Scala Bash ML Dart Crystal Transact-SQL Julia Prolog COBOL Ada Alice FoxPro D LabVIEW SAS ABAP Kotlin / _

Sign In or Register to comment.