简体   繁体   English

While循环C#/ asp.net MVC应用程序中的FormatException

[英]FormatException in while loop c#/asp.net mvc application

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 异常详细信息:System.FormatException:索引(从零开始)必须大于或等于零且小于参数列表的大小

The relPath string value is a "/Temp/pdfs/file.ext". relPath字符串值是“ /Temp/pdfs/file.ext”。 Any help? 有什么帮助吗?

The System.FormatException is thrown because a substitution marker was not found in the argument list. 抛出System.FormatException,因为在参数列表中找不到替换标记。 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. 我的答案从此处复制,其中提供了示例代码并显示了简单的修复方法。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 如何在Asp.net MVC Web应用程序c#中上传文件时显示进度? - How to show the progress while uploading a file in Asp.net MVC web application, c#? vb.net asp.net webforms application> c#asp.net mvc razor应用程序 - vb.net asp.net webforms application > c# asp.net mvc razor application 将if和else放入ASP.NET MVC C#的Foreach循环中 - Putting if and else in Foreach loop in ASP.NET MVC C# 对于 model 中的循环视图 ASP.NET MVC C# - For loop in model view ASP.NET MVC C# ASP.NET MVC 2 C#:循环内是否出现IF? - ASP.NET MVC 2 C#: Short hand IF within loop? “在ASP.NET控制台应用程序C#中抛出异常:Microsoft.SqlServer.Types.dll中的'System.FormatException'” - “Exception thrown: 'System.FormatException' in Microsoft.SqlServer.Types.dll ” in ASP.NET console application C# 将 websockets 添加到 MVC ASP.NET C# 应用程序 - Adding websockets to MVC ASP.NET C# Application C#:ASP.NET MVC应用程序的实体框架6.2 - C#: Entity Framework 6.2 for ASP.NET MVC application 将Asp.Net MVC应用程序附加到C#中的iisexpress - Attach Asp.Net MVC application to iisexpress in C# 使用C#/ ASP.net MVC建模NoSQL论坛应用程序 - Modelling a NoSQL Forum Application with C# / ASP.net MVC
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM