473,326 Members | 2,048 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,326 software developers and data experts.

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

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
2 1618
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
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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
by: Maya | last post by:
Hey, there! I'm new to vb.net and it seems I wouldn't be able to solve this without help. I have a pipe delimited file that has to be saved in txt format so it could be accepted by my DTS...
19
by: Johnny Google | last post by:
Here is an example of the type of data from a file I will have: Apple,4322,3435,4653,6543,4652 Banana,6934,5423,6753,6531 Carrot,3454,4534,3434,1111,9120,5453 Cheese,4411,5522,6622,6641 The...
5
by: Jeroen Ceuppens | last post by:
How can you set that a function returns a type, but you don't know it from before? voidunknow Function() ? unknow Function()? Thx
3
by: Antonio Maciel | last post by:
Hi. I have a datatable created at runtime that I want to display using a repeater control. The problem is that the number of columns of the datatable can vary. Is there any way to configure the...
1
by: Roy | last post by:
Hi, I have a problem that I have been working with for a while. I need to be able from server side (asp.net) to detect that the file i'm streaming down to the client is saved...
21
by: Rajen | last post by:
When I run this program. #include<stdio.h> int main() { FILE *fp; int i; float f; char str;
9
by: JimmyKoolPantz | last post by:
IDE: Visual Studio 2005 Language: VB.NET Fox Pro Driver Version: 9.0.0.3504 Problem: I currently have a problem altering a DBF file. I do not get any syntax errors when running the program. ...
3
by: adtvff | last post by:
Hi, Given a large ascii file (delimited or fixed width) with one ID field and dimensions/measures fields, sorted by dimensions, I'd like to "flatten" or "rollup" the file by creating new...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.