简体   繁体   English

使用 (Bitmap image = new Bitmap(path)) 错误.. 参数无效?

[英]Using (Bitmap image = new Bitmap(path)) Error.. Parameter not valid?

I'm trying to get an image but i get the error Parameter not valid with the following code.我正在尝试获取图像,但使用以下代码出现错误参数无效。

 if (File.Exists(MapPath(tempFolderPathAlt + "ExtractedFiles\\" + boxPath + "\\" + ArrayNode[i].TagValue)))
    {
      using (Bitmap image = new Bitmap(MapPath(tempFolderPathAlt + "ExtractedFiles\\" + boxPath + "\\" + ArrayNode[i].TagValue)))
        {
          //other code
        }
    }

The inner exception is null.内部异常为空。

在此处输入图片说明

The Path after this is mapped is:映射后的路径为:

\\C:\\Users\\Shaun\\Documents\\FormValue\\ExtractedFiles\\Box1e84b34a-522b-492e-919f-1334ee5845ff\\ca4ac72a-9ca2-4a28-b4a4-a6031b734567.png \\C:\\Users\\Shaun\\Documents\\FormValue\\ExtractedFiles\\Box1e84b34a-522b-492e-919f-1334ee5845ff\\ca4ac72a-9ca2-4a28-b4a4-a6031b734567.png

Getting an Invalid Parameter Exception for a new Bitmap(String) , where the file exists generally means that the file content is invalid and can't be parsed by any of the image type handlers.获取新Bitmap(String)的无效参数异常,其中文件存在通常意味着文件内容无效并且无法被任何图像类型处理程序解析。

One of the most common reasons for this is that the underlying file is of 0 size.最常见的原因之一是基础文件的大小为0

I got this exception when file was too large .文件太大时我得到了这个异常。

to solve it, change ' FileSizeLimitInBytes ' in registry editor要解决它,请在注册表编辑器中更改“ FileSizeLimitInBytes

  1. .Click Start, type regedit in the Start Search box, and then press ENTER.单击“开始”,在“开始搜索”框中键入 regedit,然后按 Enter。
  2. find HKEY_LOCAL_MACHINE\\SYSTEM\\CurrentControlSet\\Services\\WebClient\\Parameters找到 HKEY_LOCAL_MACHINE\\SYSTEM\\CurrentControlSet\\Services\\WebClient\\Parameters
  3. select FileSizeLimitInBytes and change the value to bigger (more than 50000000)选择 FileSizeLimitInBytes 并将值更改为更大(超过 50000000)
  4. restart your computer重启你的电脑

If it still doesn't help, you change 'FsCtlRequestTimeoutInSec' too:如果仍然没有帮助,您也可以更改“FsCtlRequestTimeoutInSec”:

  1. HKEY_LOCAL_MACHINE\\System\\CurrentControlSet\\Services\\MRxDAV\\Parameters HKEY_LOCAL_MACHINE\\System\\CurrentControlSet\\Services\\MRxDAV\\Parameters
  2. find FsCtlRequestTimeoutInSec and change the value to bigger (more than 1800 )找到 FsCtlRequestTimeoutInSec 并将值更改为更大(超过 1800 )

don't forget to restart your windows computer不要忘记重新启动 Windows 计算机

for more details https://support.microsoft.com/en-us/help/2668751/you-cannot-download-more-than-50-mb-or-upload-large-files-when-the-upl有关更多详细信息https://support.microsoft.com/en-us/help/2668751/you-cannot-download-more-than-50-mb-or-upload-large-files-when-the-upl

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

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM