Pomster
Pomster

Reputation: 15197

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.

enter image description here

The Path after this is mapped is:

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

Upvotes: 0

Views: 3273

Answers (2)

WantToDo
WantToDo

Reputation: 441

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

Upvotes: 0

Anya Shenanigans
Anya Shenanigans

Reputation: 94584

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.

Upvotes: 2

Related Questions