DaniWeb IT Discussion Community

DaniWeb IT Discussion Community (http://www.daniweb.com/forums/index.php)
-   C++ (http://www.daniweb.com/forums/forum8.html)
-   -   Get path to file found by FindFirstFile (http://www.daniweb.com/forums/thread161560.html)

praetorian20 Dec 10th, 2008 12:15 am
Get path to file found by FindFirstFile
 
Hi,
I'm using FindFirstFile and FindNextFile functions to get a list of
files from a path specified by the user.

Let's say the current directory has a sub-directory named 'subDir1'
which has a file named 'file1.txt'.

myDir <- pwd
|_ subDir1
|_ file1.txt

Now, if the user enters 'subDir1\*' as the input argument I know how
to use FindFirstFile and FindNextFile to get 'file1.txt' but I also
need to be able to retrieve the path to 'file1.txt', either absolute
or relative to the current directory. Is there any way to do this?

Thanks for your help in advance,
Ashish.

Ancient Dragon Dec 10th, 2008 12:33 am
Re: Get path to file found by FindFirstFile
 
>> Is there any way to do this?

check the user input string to see if it contains a path -- e.g. the '\' or '/' character (path separators can be either character in MS-Windows os). Copy that part in another string so that you can use it whanever needed.

praetorian20 Dec 10th, 2008 1:40 pm
Re: Get path to file found by FindFirstFile
 
Quote:

Originally Posted by Ancient Dragon (Post 754032)
>> Is there any way to do this?

check the user input string to see if it contains a path -- e.g. the '\' or '/' character (path separators can be either character in MS-Windows os). Copy that part in another string so that you can use it whanever needed.

Thanks Dragon, that works!


All times are GMT -4. The time now is 10:35 am.

Forum system based on vBulletin Copyright ©2000 - 2009, Jelsoft Enterprises Ltd.
©2003 - 2009 DaniWeb® LLC