Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations derfloh on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Query about file names during file creation????

Status
Not open for further replies.

isaisa

Programmer
Joined
May 14, 2002
Messages
97
Location
IN
hi all,

i am creating the file with the client names which i am getting from the back end[database]. The client name is having different forms i.e. it can have special characters as '-','<','&' etc. I am getting the client names in the '#' seperated array form. I am parsing the array on '#' and creating file with the parsed names.
For example; i am getting array as &quot;aaa#bbb#ccc#&quot;. The expected file names would be &quot;aaa.pdf&quot;,&quot;bbb.pdf&quot; etc.

I am getting error in case the client name consists special chars. I can not insists on the change in the database side as the project is live. I would like to check the clientnmaes.

What i wanted to know is that is there any API in win32 OR is there any MFC class which can validate the name of the client ???? Or else i need to write the function which will validate the received client names in the form of '#' seperated array.


Thanks in advance.
Sanjay
 
You can search the string for the characters that are prohibited in filenames ( \/:*?&quot;<>| ). The following code will find the prohibited characters.

CString strFileName;
strFileName = &quot;aaaa/.pdf&quot;;
if(strFileName.Find('/',0)!=-1)
{
//prohibited character found

}
else
{
//file name is okay

}

You could set up a char array holding the prohibted characters and loop through this array.

Hope this helps.
 
hi bcravens,
i did the same thing .... iterate through the array ... i was just intered to know if there is any API provided in SDK to achieve the same ...

Anyway thanks for your help.

Sanjay
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top