views:

229

answers:

2

Hi all,
I have created an application in VB6. I have to read attachments of a mail of client. But attached file has a name with invalid characters. I want to make the copy of it but my application cannot do it. So could u plz help me to solve this issue.
Thanks in advance.


EDIT: How can i check that the file name contains invalid character.

+1  A: 

The most obvious thing is to simply replace invalid characters with placeholders, so (for instance) replace ":" with "_". (Apologies if I'm missing the point.)

OT: The VB6 environment (compiler, et. al.) has been unsupported since April 2008, I'd strongly recommend using something more up-to-date. (The VB6 runtime is still supported, and will be through the lifetime of Windows 7, but even so...)

Edit: Responding to your edit:

The invalid characters in Windows filenames (since this is by its nature a Windows application) are well-documented.

T.J. Crowder
A: 

Without more detail about how you "read attachments" specific help is difficult to offer.

You might be encountering a Unicode BOM prefix, perhaps there are characters from the disallowed subset for file names, or you may be dealing with control characters or more likely characters with AscW() values > 127 such as foreign alphabet symbols and such.

You can create files with "Unicode file names" via API calls, but it may be simpler to translate such symbols to some sort of "splat" like # or _ which should work without incident. If necessary you could just iterate over the file name string character by character using AscW(char) and a Select Case statement to identify "bad" characters and replace them.

Bob Riemersma