but they did.
Had a report from a user of LNME, that LNME was producing an error message, then crashing.
The cause that an message attachment had a TAB character in it’s filename, and Windows wouldn’t accept that, so it would error.
(how the TAB got into an attachment name is another question… , for another day)
Now, if you believe Windows, there is only a small number of characters it doesn’t like in file names:
… which proves to be utter tosh. And Microsoft provides you with the proof with the Path.GetInvalidFileNameChars method.
If you use the Path.GetInvalidFileNameChars method, it will tell you there are actually 41, including both TABs.
So now, before LNME writes out the message and attachment files, LNME will now check them for more invalid characters.
What this means is …
You shouldn’t notice MUCH difference in speed, as originally I was blindly checking every filename by doing something like this:
If FilenameField <> “” Then
‘Trim Leading and Trailing space from FilenameField Field
FilenameField = FilenameField.Trim
FilenameField = Replace(FilenameField, “/”, “[SLASH]”)
FilenameField = Replace(FilenameField, “\”, “[BACKSLASH]”)
…
End If
Now I check first to see if the FilenameField has invalid characters, and if so, then do the replacement of “invalid” characters.
‘ get the list of invalid characters for this operating system
cInvalidFileNameChars = System.IO.Path.GetInvalidFileNameChars
‘ check if any of the invalid characters are in our FilenameField
iReturnValue = FilenameField.IndexOfAny(cInvalidFileNameChars)
‘ >0 means that we found some invalid characters.
If iReturnValue >= 0 Then
If FilenameField <> “” Then
‘Trim Leading and Trailing space from FilenameField Field
FilenameField = FilenameField.Trim
FilenameField = Replace(FilenameField, “/”, “[SLASH]”)
FilenameField = Replace(FilenameField, “\”, “[BACKSLASH]”)
…
End If
End If
The performance improvement appears because the majority of Subject and Attachments are correctly named, so the previous blind check will be skipped.
You can download the fixed LNME, here.