Advertisement
If you have a new account but are having problems posting or verifying your account, please email us on hello@boards.ie for help. Thanks :)
Hello all! Please ensure that you are posting a new thread or question in the appropriate forum. The Feedback forum is overwhelmed with questions that are having to be moved elsewhere. If you need help to verify your account contact hello@boards.ie
Hi there,
There is an issue with role permissions that is being worked on at the moment.
If you are having trouble with access or permissions on regional forums please post here to get access: https://www.boards.ie/discussion/2058365403/you-do-not-have-permission-for-that#latest

accessing directories c++ DOS

  • 07-12-2002 10:37pm
    #1
    Posts: 0


    Hey all,

    Does anyone have an idea on how to access directories through c++?

    I'm sure there's a simple way to do it, it's wrecking my head at the mo, i'd like to display the listing of the directory, find the executable files and display a menu, giving the option to execute them.

    I'm sure it would be better through batch files but I'd like to see i could use directories through c++.

    Any help would be great
    thanks


Comments

  • Closed Accounts Posts: 5,564 ✭✭✭Typedef


    In DOS not a clue.

    If you are allowed to use *nix (or indeed if the pertinent libraries have been ported to mingw) you might want to check out dirent.

    man dirent.


  • Posts: 0 [Deleted User]


    thanks :)


  • Closed Accounts Posts: 1,006 ✭✭✭theciscokid


    i probably way off here but is that not

    C:\Documents and Settings\theciscokid>

    C:\Documents and Settings\theciscokid>cd desktop

    C:\Documents and Settings\theciscokid\desktop>

    then just do dir for a list


  • Registered Users, Registered Users 2 Posts: 95 ✭✭Mr.StRiPe


    The code within this function should do the trick. It displays all files with .DEMO extensions in the specified dir. You should be able to modify it to what ever you want. You'll also need to #include <io.h>

    void dir()
    {
    index = 0;
    struct _finddata_t demo_file;
    long hFile;


    /* Find first .demo file in current directory */
    if( (hFile = _findfirst( "data/demos/*.demo", &demo_file )) == -1L )
    {
    //print( "No *.demo files in current directory!" );
    strcpy(demofile[index++], "No *.demo files in current directory!");
    }


    else
    {

    //print( "Listing of .demo files" );endl();endl();

    strcpy(demofile[index++], demo_file.name);
    //print(demo_file.name);endl();

    /* Find the rest of the .demo files */
    while( _findnext( hFile, &demo_file ) == 0 )
    {
    strcpy(demofile[index++], demo_file.name);
    //print(demo_file.name); endl();
    }

    _findclose( hFile );
    }
    }


  • Posts: 0 [Deleted User]


    Thanks for the code snippet
    :)


  • Advertisement
Advertisement