Thread: directory/file

  1. #1
    Registered User Cpro's Avatar
    Join Date
    Oct 2006
    Posts
    149

    directory/file

    I want to create a program that finds a folder, opens it, and goes through each file in that folder. I'm not sure how to go about this, and i was wondering if anyone could point me in the right direction. I looked at the faq on this site, but none of the code worked (dir.h or dirent.h couldn't be found). I need it to be for a console application. I know how to open individual files, but not a folder, and each file in the folder.

    Thanks.
    IDE - Visual Studio 2005
    Windows XP Pro

  2. #2
    Registered User
    Join Date
    Dec 2007
    Posts
    2,675
    I'm guessing this is on Windows OS if dirent.h was not found, and I think you did not finish reading the FAQ entry.

  3. #3
    Registered User Cpro's Avatar
    Join Date
    Oct 2006
    Posts
    149
    "I'm guessing this is on Windows OS if dirent.h was not found, and I think you did not finish reading the FAQ entry."

    Are you referring to the Win32 example? I thought this was a Windows Program (not console). I got a bunch of errors when i compiled it.
    Code:
    error C2664: 'FindFirstFileW' : cannot convert parameter 1 from 'const char [4]' to 'LPCWSTR'	
    error C2664: 'GetCurrentDirectoryW' : cannot convert parameter 2 from 'char [260]' to 'LPWSTR'	
    error C2664: 'SetCurrentDirectoryW' : cannot convert parameter 1 from 'char *' to 'LPCWSTR'	
    error C2664: 'SetCurrentDirectoryW' : cannot convert parameter 1 from 'char [260]' to 'LPCWSTR'	
    error C2664: 'SetCurrentDirectoryW' : cannot convert parameter 1 from 'const char [3]' to 'LPCWSTR'	
    error C2664: 'strcmp' : cannot convert parameter 1 from 'const WCHAR [260]' to 'const char *'	
    error C2664: 'strcmp' : cannot convert parameter 1 from 'WCHAR [260]' to 'const char *'
    error C2664: 'strcmp' : cannot convert parameter 1 from 'WCHAR [260]' to 'const char *'
    By the way, is there something i'm doing wrong. Because, everytime i copy and paste some code from Windows Programming tutorials (including this site), i always get these types of errors about converting parameter to LPCWSTR.

    Thanks.
    IDE - Visual Studio 2005
    Windows XP Pro

  4. #4
    Registered User
    Join Date
    Dec 2007
    Posts
    2,675
    Cool, you found the Windows one. Where you mentioned dirent.h I thought maybe you didn't scroll down far enough.

    The reason for your compilation errors are also part of another FAQ.

  5. #5
    Registered User Cpro's Avatar
    Join Date
    Oct 2006
    Posts
    149
    Ahh, that fixed it.

    Thanks.
    IDE - Visual Studio 2005
    Windows XP Pro

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Adding directory/file names to a linked list
    By thoseion in forum C Programming
    Replies: 13
    Last Post: 12-08-2006, 01:13 PM
  2. treeview directory/file list
    By JaWiB in forum Windows Programming
    Replies: 6
    Last Post: 01-29-2006, 05:43 PM
  3. Directory/File info
    By Anonymous in forum Linux Programming
    Replies: 3
    Last Post: 03-21-2002, 01:47 PM