Workgin PNG File via String

dneisler

Member
Joined
Sep 6, 2005
Messages
7
Programming Experience
1-3
Working with PNG File via String

I am working on a Fedex Project and I have a slight issue as i have never delt with this before. I have a String strLabel that contains the PNG label fedex returns to me. How do I write this to a PNG file to open on my hard drive.

Any assistance wrould be great.
 
on hard drive???
I assume you want to display adequate PNG image on the form or moreover in PictureBox ... in that case you can simply do the next:

Dim strLabel As String = "picture1"
PictureBox1.Image = Image.FromFile("C:\" & strLabel & ".png") 'assuming that file is stored in C:\ root


Regards ;)

Wellcome to the forum :)
 
No, fedex is returning to me a xml document, and I parse out the label node, which is a string. The string is actuall the Fedex Shipping label that I will beed to print. I just need to save that to a File.PNG on my hard drive. Not read the file from hard drive as you do above.

This is what I am currenting trying to use:

Dim strLabel as String
strLabel = oNode.InnerText

Dim fs As FileStream fs = New FileStream(Application.StartupPath & "\Test.PNG", FileMode.CreateNew)
Dim bw As BinaryWriter = New BinaryWriter(fs)
bw.Write(strLabel)
bw.Close()
 
Sorry, I'm not quite following your question.
FedEx returns to you an XML document which contains a string representation of a shipping label? Is the string a path to the file, is it a binary respresentation of the image, or ...?
If it is just a simple text message that you want to save as a .png then you would want to look into GDI+: the System.Drawing.Graphics Class (the Graphics.DrawString method especially), the System.Drawing.Image Class, etc...
 
Fedex was returning a Base 64 string to me for the image itself, once I found out it was base64 I got it fixed with little problem.


Thanks everyone.
 
Back
Top