Thread: directories

  1. #1
    Registered User
    Join Date
    Jan 2002
    Posts
    64

    directories

    hi guys,

    im quite new to c++ and i ve only written bits of code for college as examples, but no full apps now i want to write something useful for a change.

    i want to write a program to list whats in a directory with a command, like dir in dos, how would i list whats in a directory and check to see whether or not a directory is valid.

    thanks a lot.

    Shakespeare.

  2. #2
    Registered User hk_mp5kpdw's Avatar
    Join Date
    Jan 2002
    Location
    Northern Virginia/Washington DC Metropolitan Area
    Posts
    3,817
    It would help a bit if you let us know what OS you are developing your app for and what compiler you will be using.
    "Owners of dogs will have noticed that, if you provide them with food and water and shelter and affection, they will think you are god. Whereas owners of cats are compelled to realize that, if you provide them with food and water and shelter and affection, they draw the conclusion that they are gods."
    -Christopher Hitchens

  3. #3
    Registered User
    Join Date
    Jan 2002
    Posts
    64
    i'm developing in Windows XP and using ms Visual studio

  4. #4
    dragon
    Guest

    same problem

    I have the same problem, but I'm using Linux/g++!

  5. #5
    Unregistered 4444
    Guest
    Somebody told me I could do something like this for windows

    You need to fill a WIN32_FIND_DATA struct with a call to FindFirstFile() and then iterate through the directory with FindNextFile() until it returns INVALID_HANDLE_VALUE. Each time FindNextFile() returns sucessfully the filename will be a member of the WIN32_FIND_DATA struct which you could use to fill an array. You'll need to include windows.h; search the boards/MSDN for an example if needed.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Comparing 2 directories
    By Opel_Corsa in forum C++ Programming
    Replies: 4
    Last Post: 01-19-2007, 11:30 PM
  2. VC6 directories
    By Magos in forum Tech Board
    Replies: 0
    Last Post: 03-11-2005, 05:52 PM
  3. problem while opening files from multiple directories
    By V.G in forum Windows Programming
    Replies: 2
    Last Post: 11-08-2004, 03:29 PM
  4. mkdir and multiple directories
    By Idle in forum C Programming
    Replies: 4
    Last Post: 06-28-2003, 04:56 AM
  5. Working with directories...
    By C Seņor in forum C Programming
    Replies: 4
    Last Post: 04-20-2002, 11:45 AM