0

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

5
  • 3
    If your path actually starts with a back-slash that will be your problem. Commented May 10, 2013 at 10:15
  • @AshBurlaczenko , so they need to be forward slash's? Commented May 10, 2013 at 10:17
  • 2
    I've seen this error when the file is empty as well Commented May 10, 2013 at 10:17
  • 1
    Hey thanks, i just checked my picture file and its empty. Commented May 10, 2013 at 10:18
  • @Petesh If you would post an answer i will gladly mark it as correct. Commented May 10, 2013 at 11:08

2 Answers 2

2

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.

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

Comments

0

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

Comments

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.