Click to See Complete Forum and Search --> : Directory Path
Tony Best
July 30th, 1999, 08:59 AM
I need to set a path based on a varible.
a CString holds a dir name ... ex. AC1019
so i need to set the path similar to this
char dir[128] = "c:\\AC1019\\*.*";
but the AC1019 has to change depending on what directory the user chose how do I do that?
Tony
ChristianM
July 30th, 1999, 09:18 AM
i am not sure that i understand..
if yes.. try this :
strcpy(dir,"C:\\");
strcat(dir,m_string); //m_string is your CString
strcat(dir,"\\*.*");
if i dont understand.. give more info .. thanks..
Tony Best
July 30th, 1999, 09:59 AM
Perfect!
Thanks so much
You don't know anything about setting registry setting for a program do you?
Tony
Rishi
July 30th, 1999, 11:01 AM
Use strtok to find out the first \ and then use that pointer to copy characters from CString depeding upon its length
Ravi Bhavnani
July 30th, 1999, 11:31 AM
Tony,
Since you're using CString, it's better to do:
CString strDir;
CString strWildcard;
strDir = "AC1019";
strWildcard.Format ("C:\\%s\\*.*", strDir);
This has the advantage of being internationalized, if you choose to build your product for languages other than English.
Another tip - as far as possible, don't use literal strings like "C:\\". Instead, create a string resource and use that to format strDir.
For example, create a string resource (ID = IDS_Wildcard) that contains "C:\\%s\\*.*" and do the following:
CString strDir;
CString strWildcard;
strDir = "AC1019";
strWildcard.Format (IDS_Wildcard, strDir);
This makes the code much more maintainable, since the wildcard spec is isolated in a single location.
/ravi
codeguru.com
Copyright Internet.com Inc., All Rights Reserved.