|
-
July 30th, 1999, 08:59 AM
#1
Directory Path
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
-
July 30th, 1999, 09:18 AM
#2
Re: Directory Path
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..
-
July 30th, 1999, 09:59 AM
#3
Re: Directory Path
Perfect!
Thanks so much
You don't know anything about setting registry setting for a program do you?
Tony
-
July 30th, 1999, 11:01 AM
#4
Re: Directory Path
Use strtok to find out the first \ and then use that pointer to copy characters from CString depeding upon its length
-
July 30th, 1999, 11:31 AM
#5
Re: Directory Path
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
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
|