What is the problem with this conditional loop:
while (System.IO.File.Exists(relPath)){ ... }
It trows an exception when it starts:
Exception Details: System.FormatException: Index (zero based) must be greater than or equal to zero and less than the size of the argument list
The relPath string value is a "/Temp/pdfs/file.ext". Any help?
StackTracein the exception? (not the call stack where the debugger stopped) Also, please don't HTML-escape code on SO; see stackoverflow.com/editing-help#codethrow e; it destroys the stack trace. (which is why you have no idea what the problem is here) Instead, writethrow;, or get rid of the stack trace entirely.