Thread: Help with folders

  1. #1
    Registered User
    Join Date
    Oct 2006
    Posts
    118

    Question Help with folders

    Hi,

    For a small project I am creating, I need to use not just files (boy, would that be nice!), but I need to interact with folders. among the things that need to be accomplished are: searching folders, collecting folder contents, and dealing with searching for folders. Normally I would just use files so that I would be able to use fstream, but thats just not possible for this.

    Can anybody point me to a page that explains how to interact with folders in these ways?

    Thanks!

    FlyingIsFun1217

  2. #2
    Registered User
    Join Date
    Jan 2005
    Posts
    7,366
    Folders generally require platform specific code. An excellent solution is to use Boost filesystem, which works on most platforms and allows you to write the same code no matter which platform you are using (it works by using different internal code depending on which platform you use).

    You can also indicate which platform (OS, compiler) you have so people can recommend specific resources on folders.

  3. #3
    Registered User
    Join Date
    Oct 2006
    Posts
    118
    As to those one-size-fits-all sort of methods, I will check those out...

    Right now I am using Windows, but would like my program to be able to be run on Linux too, if that is possible.

    Thanks for the help!

    FlyingIsFun1217

  4. #4
    Registered User
    Join Date
    Oct 2006
    Posts
    118
    Ok, after checking some stuff out, I found that using an #include <windows.h>, you can use a CreateDirectory function. Is this possible in C++? If so, can anybody link me to a page that is noob-understandable?

    Thanks!

    FlyingIsFun1217

  5. #5
    erstwhile
    Join Date
    Jan 2002
    Posts
    2,227
    FAQ > How do I... (Level 3) > Accessing a directory and all the files within it.

    Since you already know the winapi function name then use google to find the msdn page that describes CreateDirectory. You can also search these boards for specific examples of its use.
    CProgramming FAQ
    Caution: this person may be a carrier of the misinformation virus.

  6. #6
    Registered User
    Join Date
    Oct 2006
    Posts
    118
    For right now, I am using:

    mkdir("C:/");

    In the future though, I may use the other method.

    Thank you for the links and the help!

    FlyingIsFun1217

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Error while trying to list folders
    By Hellbinder in forum Networking/Device Communication
    Replies: 5
    Last Post: 06-12-2009, 05:27 PM
  2. geting full path of files and folders (boost::filesystem)
    By umen242 in forum C++ Programming
    Replies: 2
    Last Post: 05-18-2008, 11:37 PM
  3. Problems Moving Certain Folders...
    By notsocks in forum C Programming
    Replies: 8
    Last Post: 12-16-2007, 07:25 AM
  4. Deleting folders and sub folders
    By Boomba in forum C++ Programming
    Replies: 30
    Last Post: 06-11-2003, 11:58 AM
  5. Folders and text files
    By tim545666 in forum C++ Programming
    Replies: 11
    Last Post: 02-17-2002, 04:15 PM