First off, check your regex: that won't work:
^\D+
Matches numbers at the start of the text, and your description doesn't show that: "tes001text.txt" does not match your pattern at all.
^tes\D+
would, but ...
Regex.Replace Method (String, String) (System.Text.RegularExpressions)[
^] does not return the "bit it removed", so your attempt to parse the number is goign to fail as well because you have specifcally removed the number from the string you are trying to parse!
Stop guessing: read up on Regexes, and get a copy of
Expresso[
^] - it's free, and it examines, tests, and generates Regular expressions.
But... why the heck are you even trying to parse the number when you presumably need the number from the previous row to work out what number to give this one?