Thread: isDirectory() in C/C++

  1. #1
    Registered User
    Join Date
    Jan 2003
    Posts
    8

    isDirectory() in C/C++

    Is there any way for me to check for a directory in C or C++...in Java there is an isDirectory() function

    Thanks.

    Stan

  2. #2
    End Of Line Hammer's Avatar
    Join Date
    Apr 2002
    Posts
    6,231
    That's compiler/OS specific. What are you using?
    When all else fails, read the instructions.
    If you're posting code, use code tags: [code] /* insert code here */ [/code]

  3. #3
    Registered User
    Join Date
    Jan 2003
    Posts
    8

    isDirectory function in C

    Is there any way for me to check for a directory in C or C++...in Java there is an isDirectory() function

    Im using Micosoft Visual C++

    Thanks.

    Stan

  4. #4
    Registered User Vber's Avatar
    Join Date
    Nov 2002
    Posts
    807

    You asked this once.

    Click in 'Post reply' to reply an message, instead writing a new one.

  5. #5
    Registered User
    Join Date
    Jan 2003
    Posts
    8
    Im using Microsoft Visual C++ 6.0

  6. #6
    Registered User Vber's Avatar
    Join Date
    Nov 2002
    Posts
    807

    try searching in MSDN.

    http://msdn.microsoft.com/library/de...sdirectory.asp

    you'll find sure, what you're searching.

  7. #7
    Registered User
    Join Date
    Jan 2003
    Posts
    8
    Thanks Vber ....I appreciate the help, if u ever need a vacation then mi casa es su casa

  8. #8
    Registered User Vber's Avatar
    Join Date
    Nov 2002
    Posts
    807

    ...

    Thanks Vber ....I appreciate the help, if u ever need a vacation then mi casa es su casa
    No problem

  9. #9
    Registered User
    Join Date
    Jan 2003
    Posts
    8
    How do i delete a file once i have ascertained it is a file ?


    thanks

  10. #10
    End Of Line Hammer's Avatar
    Join Date
    Apr 2002
    Posts
    6,231
    Originally posted by yardy
    How do i delete a file once i have ascertained it is a file ?


    thanks
    If you want a standard C method, try this, else search MSDN if you want an MS specific version.
    When all else fails, read the instructions.
    If you're posting code, use code tags: [code] /* insert code here */ [/code]

  11. #11
    fou
    Guest
    Since this is a C board, here is a method to determine if a path is a directory in WinApi C.

    Code:
    attrib = GetFileAttributes(path);
    
    if ( attrib == 0xFFFFFFFF || !(attrib & FILE_ATTRIBUTE_DIRECTORY) ){
    	/* not a valid directory */
    }
    And here is the link for DeleteFile:
    http://msdn.microsoft.com/library/de...deletefile.asp

    Note: Google is far more effective for searching msdn than the ms search engine.

    Have Fun!

  12. #12
    Registered User
    Join Date
    Feb 2003
    Posts
    3

    Question

    Hi

    I am wondering if there is a similar method or standard function I can use on UNIX platform ( Though I could not find one in any manulas I looked at)?

    I would like to ensure that a directory path is valid before I start processing. At the point I do this I do not know if the directory has any files in it.

    Thanks in advance.

    Mike

  13. #13
    End Of Line Hammer's Avatar
    Join Date
    Apr 2002
    Posts
    6,231
    When all else fails, read the instructions.
    If you're posting code, use code tags: [code] /* insert code here */ [/code]

Popular pages Recent additions subscribe to a feed