On a new job "Cleaning up" some code and getting familiar with things... This is in C# .NET, but the WTF is good in any language. The cycles wasted here are criminal.
First our guy wants the filename from a fully qualified path. So creates a regex in order to split the string on a backslashes...
regex = new Regex (@"\\");
string[] parts = regex.Split(xFile.PostedFile.FileName.ToString());
next he does a for each (without curlies{} for shame) assigning the current element to our variable... Untill we fall out. You heard me, we simply fall out of the for statement. and the last element is the filename. This guy does the same thing for extensions he just splits on the dot. argh! not even a parts[parts.Length - 1]
foreach (string part in parts)
strFileReviewName=part.ToString();
in .NET for those who may not use it the following is all thats needed
sfName = Path.GetFileName(xFile.PostedFile.FileName)
sExt = Path.GetExtension(xFile.PostedFile.FileName)
Thanks for sharing my pain,
Joe Johnston