0

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?

5
  • @SLaks Check post update. Thank you for your attention Commented Feb 3, 2013 at 1:14
  • Is that line 605? If so, your build is probably out of date. Commented Feb 3, 2013 at 1:20
  • What's the StackTrace in the exception? (not the call stack where the debugger stopped) Also, please don't HTML-escape code on SO; see stackoverflow.com/editing-help#code Commented Feb 3, 2013 at 1:21
  • @SLaks I´ll fix my post, Line 605 is the catch part of the try catch exception. "trow e". What you mean my build is out of date? Commented Feb 3, 2013 at 1:25
  • 2
    Never write throw e; it destroys the stack trace. (which is why you have no idea what the problem is here) Instead, write throw;, or get rid of the stack trace entirely. Commented Feb 3, 2013 at 3:56

1 Answer 1

1

The System.FormatException is thrown because a substitution marker was not found in the argument list. If more arguments were provided, the program would not throw an exception.

My answer is copied from here, which provides sample code and shows the simple fix.

Sign up to request clarification or add additional context in comments.

1 Comment

It is a while condition.... does not make sense. It is a function that returns true if file exist or false in case it does not.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.