Click here to Skip to main content
15,902,922 members
Home / Discussions / C#
   

C#

 
AnswerRe: WMI unable to connect to some machines Pin
Dave Kreskowiak4-Jan-07 2:58
mveDave Kreskowiak4-Jan-07 2:58 
QuestionContextMenu in ShockWaveFlash Pin
morteza573-Jan-07 3:50
morteza573-Jan-07 3:50 
QuestionConverting an Image to a Byte[] and visa versa Pin
Gareth H3-Jan-07 3:38
Gareth H3-Jan-07 3:38 
AnswerRe: Converting an Image to a Byte[] and visa versa Pin
Luc Pattyn3-Jan-07 4:32
sitebuilderLuc Pattyn3-Jan-07 4:32 
GeneralRe: Converting an Image to a Byte[] and visa versa Pin
Gareth H3-Jan-07 5:30
Gareth H3-Jan-07 5:30 
GeneralRe: Converting an Image to a Byte[] and visa versa Pin
Luc Pattyn3-Jan-07 9:37
sitebuilderLuc Pattyn3-Jan-07 9:37 
GeneralRe: Converting an Image to a Byte[] and visa versa Pin
Gareth H3-Jan-07 22:38
Gareth H3-Jan-07 22:38 
GeneralRe: Converting an Image to a Byte[] and visa versa [modified] Pin
Gareth H5-Jan-07 0:57
Gareth H5-Jan-07 0:57 
Ive kind of fixed the problem. Its being caused because i dont have write permissions i think, because if i specifiy the actual file location, eg: C:\ci.gif, i dont get the error. But if i try to get the image from my get/set method, the error appears.

The next problem i get through is when converting the image to bytes and visa versa.

public string ImageToByteConvert(Image imageIn)<br />
{<br />
  MemoryStream ms = new MemoryStream();<br />
  imageIn.Save(ms, ImageFormat.Gif);<br />
<br />
  string imageString = Convert.ToBase64String(ms.ToArray());<br />
  return imageString;<br />
}


I then write that string to the XML file which works fine. But if i try to read it back

byte[] imageByte = encoding.GetBytes(attribute.Value);<br />
retval.Image = ByteToImageConvert(imageByte);


I get an error saying:

05/01/2007 11:57:37 XmlModelSave.ReadGraph; Exception: System.ArgumentException: Parameter is not valid.<br />
  at System.Drawing.Image.FromStream(Stream stream, Boolean useEmbeddedColorManagement, Boolean validateImageData)<br />
  at System.Drawing.Image.FromStream(Stream stream)


Which i believe to mean the bytes that i have just converted back from a string, arnt valid for the image im trying to create. But im unsure how to solve this.

Regards,
Gareth.
GeneralRe: Converting an Image to a Byte[] and visa versa Pin
Luc Pattyn5-Jan-07 2:40
sitebuilderLuc Pattyn5-Jan-07 2:40 
GeneralRe: Converting an Image to a Byte[] and visa versa Pin
Gareth H5-Jan-07 3:27
Gareth H5-Jan-07 3:27 
AnswerRe: Converting an Image to a Byte[] and visa versa Pin
maysam gamini5-Nov-09 12:49
maysam gamini5-Nov-09 12:49 
QuestionHow to trigger event when user press Enter key in textbox? Pin
TrooperIronMan3-Jan-07 3:24
TrooperIronMan3-Jan-07 3:24 
AnswerRe: How to trigger event when user press Enter key in textbox? Pin
Martin#3-Jan-07 3:31
Martin#3-Jan-07 3:31 
AnswerRe: How to trigger event when user press Enter key in textbox? Pin
Vertyg03-Jan-07 3:34
Vertyg03-Jan-07 3:34 
GeneralRe: How to trigger event when user press Enter key in textbox? Pin
Martin#3-Jan-07 3:35
Martin#3-Jan-07 3:35 
GeneralRe: How to trigger event when user press Enter key in textbox? Pin
Vertyg03-Jan-07 4:48
Vertyg03-Jan-07 4:48 
GeneralRe: How to trigger event when user press Enter key in textbox? Pin
Martin#3-Jan-07 4:54
Martin#3-Jan-07 4:54 
AnswerRe: How to trigger event when user press Enter key in textbox? Pin
V.3-Jan-07 4:34
professionalV.3-Jan-07 4:34 
GeneralRe: How to trigger event when user press Enter key in textbox? Pin
TrooperIronMan3-Jan-07 6:43
TrooperIronMan3-Jan-07 6:43 
AnswerRe: Strange string.Format() error Pin
Dominik Reichl3-Jan-07 2:13
Dominik Reichl3-Jan-07 2:13 
GeneralRe: Strange string.Format() error Pin
Vertyg03-Jan-07 2:20
Vertyg03-Jan-07 2:20 
QuestionSet Regional Settings for CE 5.0 Pin
Tyler453-Jan-07 2:02
Tyler453-Jan-07 2:02 
QuestionAccess Network through asp.net 2.0 application Pin
abhinish3-Jan-07 0:53
abhinish3-Jan-07 0:53 
AnswerRe: Access Network through asp.net 2.0 application Pin
Not Active3-Jan-07 2:09
mentorNot Active3-Jan-07 2:09 
QuestionDisplaying + (Plus) sign to node without adding child node Pin
s v joshi3-Jan-07 0:38
s v joshi3-Jan-07 0:38 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.