|
-
May 17th, 1999, 01:45 AM
#1
Reading filenames from directories...
I would like to write some code that can compile lists of files in directories. Using the CFileFind class, I've been successful at getting the filenames. The problem is (and this may sound silly) that I don't know how to set the working directory for the CFileFind operation. The only way I have been able to do this is by setting the ENTIRE project's working directory. What is the command used to change the working directory during program execution?
Thanks,
Randy
-
May 17th, 1999, 02:08 AM
#2
Re: Reading filenames from directories...
Hi!
U can use _chdir to change the current working directory.The _chdir function changes the current working directory to the directory specified by dirname. The dirname parameter must refer to an existing directory. This function can change the current working directory on any drive and if a new drive letter is specified in dirname, the default drive letter will be changed as well. For example, if A is the default drive letter and \BIN is the current working directory, the following call changes the current working directory for drive C and establishes C as the new default drive:
_chdir("c:\\temp");
U need to #include the direct.h header file.
#include <direct.h>
Do let me know if it works.
Regards,
Sukanya Swaminathan
Software Engineer
Aditi Technologies
Blore - 80
Web Page :www.aditi.com
-
May 17th, 1999, 02:16 AM
#3
Re: Reading filenames from directories... (IT WORKED)
-
May 17th, 1999, 05:01 AM
#4
Re: Reading filenames from directories... (IT WORKED)
Be sure to save the current dir, and set it back when finished, as its not nice to change the working dir on the user.
Another way is to specify the directory in the filter for CFileFind::FindFile.
E.g.:CFileFind fileFind;
fileFind.FindFile("c:\\tmp\\*.*")
This works with FindFirstFile/FindNextFile, so I presume it should work here also.
-
May 17th, 1999, 07:38 AM
#5
Re: Reading filenames from directories... (IT WORKED)
It does, I always use this method as I hesitate on changing the current workingdirectory for a user
multi threaded applications can get really upset if you do...
Sally
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|