简体   繁体   中英

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

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.

One of the most common reasons for this is that the underlying file is of 0 size.

I got this exception when file was too large .

to solve it, change ' FileSizeLimitInBytes ' in registry editor

  1. .Click Start, type regedit in the Start Search box, and then press ENTER.
  2. find HKEY_LOCAL_MACHINE\\SYSTEM\\CurrentControlSet\\Services\\WebClient\\Parameters
  3. select FileSizeLimitInBytes and change the value to bigger (more than 50000000)
  4. restart your computer

If it still doesn't help, you change 'FsCtlRequestTimeoutInSec' too:

  1. HKEY_LOCAL_MACHINE\\System\\CurrentControlSet\\Services\\MRxDAV\\Parameters
  2. find FsCtlRequestTimeoutInSec and change the value to bigger (more than 1800 )

don't forget to restart your windows computer

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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