On 3/1/06, Ron Grabowski (JIRA) <firstname.lastname@example.org> wrote:
> [ http://issues.apache.org/jira/browse/LOG4NET-66?page=comments#action_12368446 ]
> Ron Grabowski commented on
> I don't like the idea of using a regular expression to match filenames:
It is a bit heavy handed anyway. I'll try to remove it and post a new patch against the current version.
> "^" + Path.GetFileNameWithoutExtension(baseFileName) + "(\\.[0-9]*)?
" + Path.GetExtension(baseFileName) + "$"
> Wouldn't these filenames cause the regular expression to misbehave (square brackets, parenthesis, and the period have special meaning in regular expressions)?
Regular expressions allow you to match against source text including its special characters by prefixing the special character in the pattern with a back-slash.
Filenames with numeric extensions should never be generated when preserveFileNameExtension is used. Maybe it needs warning text (like that for staticFileName) highlighting that strange things need to happen if you don't clear the directory first.
> Is there a way to use DirectoryInfo's GetFiles style searching (DOS wildcards) to achieve the same result?
Not that I've thought of.
What might have been better is to explicitly specify the extension to be used and to remove the extension from the base filename. This would probably fit in somewhat better with the original (non-extension preserving code) and might even reduce overhead.