By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
454,420 Members | 1,417 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 454,420 IT Pros & Developers. It's quick & easy.

Unknow File Format - How can i solve it???

P: n/a
Hi;
I use the method below to save the an image showed in a
Picture Box using the SaveFileDialog.

protected void SaveImage()
{
try
{
Stream stream = File.OpenWrite
(this.CaminhoImagem);
using (StreamWriter writer = new StreamWriter
(stream))
{
writer.Write (this.pctImagem.Image.Clone ());
}
}
catch (IOException ex)
{
MessageBox.Show (ex.Message, "Harpia - Erro de
Gravação",
MessageBoxButtons.OK, MessageBoxIcon.Error);
}
}//final do metodo

The method running very well and don't show me any error.
Is impossible to open the saved image because the image
format is wrong. Always i see the message: "UNKNOWN FILE
FORMAT"
How can i solve this problem???

Nov 15 '05 #1
Share this Question
Share on Google+
2 Replies


P: n/a
Thomaz Pereira <su***@nce.ufrj.br> wrote:
I use the method below to save the an image showed in a
Picture Box using the SaveFileDialog.

protected void SaveImage()
{
try
{
Stream stream = File.OpenWrite
(this.CaminhoImagem);
using (StreamWriter writer = new StreamWriter
(stream))
{
writer.Write (this.pctImagem.Image.Clone ());
}
}


You're using a StreamWriter, which is designed for character data - but
you want to write binary data. Why have you created a StreamWriter at
all? Further, you're basically writing the result of Image.ToString(),
which I can't see being particularly helpful.

I suggest you use pctImagem.Image.Save instead.

--
Jon Skeet - <sk***@pobox.com>
http://www.pobox.com/~skeet
If replying to the group, please do not mail me too
Nov 15 '05 #2

P: n/a
HI Thomas,

I posted the answer in your other post.
It's a lot simpler that this, all you have to do is a
this.pctImagem.Image.Save( .... );

Cheers,

--
Ignacio Machin,
ignacio.machin AT dot.state.fl.us
Florida Department Of Transportation

"Thomaz Pereira" <su***@nce.ufrj.br> wrote in message
news:e5****************************@phx.gbl...
Hi;
I use the method below to save the an image showed in a
Picture Box using the SaveFileDialog.

protected void SaveImage()
{
try
{
Stream stream = File.OpenWrite
(this.CaminhoImagem);
using (StreamWriter writer = new StreamWriter
(stream))
{
writer.Write (this.pctImagem.Image.Clone ());
}
}
catch (IOException ex)
{
MessageBox.Show (ex.Message, "Harpia - Erro de
Gravação",
MessageBoxButtons.OK, MessageBoxIcon.Error);
}
}//final do metodo

The method running very well and don't show me any error.
Is impossible to open the saved image because the image
format is wrong. Always i see the message: "UNKNOWN FILE
FORMAT"
How can i solve this problem???
Nov 15 '05 #3

This discussion thread is closed

Replies have been disabled for this discussion.