Bitmap Save method gives "Parameter is not valid"

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I have an image which I'm trying to save using

my_image.Save(some_path, System.Drawing.Imaging.ImageFormat.Path);

and then I get the error "Parameter is not valid".
What could be the reason for this error? I know I can store it as a Png file.
 
I have an image which I'm trying to save using

my_image.Save(some_path, System.Drawing.Imaging.ImageFormat.Path);

and then I get the error "Parameter is not valid".
What could be the reason for this error? I know I can store it as a Png file.

ImageFormat.Path doesn't exist as far as I can see. Try changing it to
Jpeg just to test. What format do you want to save it as?
 
Sorry, I wrote wrong. It should be Png

DeveloperX said:
ImageFormat.Path doesn't exist as far as I can see. Try changing it to
Jpeg just to test. What format do you want to save it as?
 
An existing path, including file name (which does not exist).






- Show quoted text -

Check what the string holds. If you've got something like

string some_path = "C:\pics\whatever";
that will actually turn the \p and \w into escape codes (if they're
valid ones)

so use the @ like so:
string some_path = @"C:\pics\whatever";

if you've got my_image.Save("C:\mypath",
System.Drawing.Imaging.ImageFormat.Png);
again just put an @ at the start.
my_image.Save(@"C:\mypath", System.Drawing.Imaging.ImageFormat.Png);
 
I've got double backslash (\\).

DeveloperX said:
Check what the string holds. If you've got something like

string some_path = "C:\pics\whatever";
that will actually turn the \p and \w into escape codes (if they're
valid ones)

so use the @ like so:
string some_path = @"C:\pics\whatever";

if you've got my_image.Save("C:\mypath",
System.Drawing.Imaging.ImageFormat.Png);
again just put an @ at the start.
my_image.Save(@"C:\mypath", System.Drawing.Imaging.ImageFormat.Png);
 
I'm having the same problem...my path is correct, and the ImageFormat is correct. But it continues to give me the same error "Parameter is not valid"

If you figured the solution out, please post, I'll continue to look around.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top