thenrich
asked on
.WMF to XML
Is there a program I can use to make .wmf file into an XML file in then in .NET make the XML back into a .WMF again?
Private Sub FromXML(ByVal XMLPath As String, ByVal FilePath As String)
Dim oArray() As Byte
Dim oStreamReader As System.IO.StreamReader
Dim oSerialiser As New System.Xml.Serialization.X mlSerializ er(GetType (Byte()))
Dim oFileStream As System.IO.FileStream
Try
oStreamReader = System.IO.File.OpenText(XM LPath)
oArray = oSerialiser.Deserialize(oS treamReade r)
oStreamReader.Close()
oFileStream = System.IO.File.Open(FilePa th, IO.FileMode.OpenOrCreate)
oFileStream.Write(oArray, 0, oArray.Length)
oFileStream.Close()
Catch ex As Exception
MsgBox(ex.Message)
End Try
End Sub
Private Sub ToXML(ByVal XMLPath As String, ByVal FilePath As String)
Dim oArray() As Byte
Dim oStreamWriter As System.IO.StreamWriter
Dim oSerialiser As New System.Xml.Serialization.X mlSerializ er(GetType (Byte()))
Dim oFileStream As System.IO.FileStream
Try
oFileStream = System.IO.File.Open(FilePa th, IO.FileMode.Open)
ReDim oArray(oFileStream.Length - 1)
oFileStream.Read(oArray, 0, oFileStream.Length)
oFileStream.Close()
oStreamWriter = System.IO.File.CreateText( XMLPath)
oSerialiser.Serialize(oStr eamWriter, oArray)
oStreamWriter.Close()
Catch ex As Exception
MsgBox(ex.Message)
End Try
End Sub
Call the ToXML sub with the path you want to save the XML to and the file you want to create it from.
Call the FromXML sub with the path of the XML Document and the path you want to save the data to.
Will work for any file type.
Dim oArray() As Byte
Dim oStreamReader As System.IO.StreamReader
Dim oSerialiser As New System.Xml.Serialization.X
Dim oFileStream As System.IO.FileStream
Try
oStreamReader = System.IO.File.OpenText(XM
oArray = oSerialiser.Deserialize(oS
oStreamReader.Close()
oFileStream = System.IO.File.Open(FilePa
oFileStream.Write(oArray, 0, oArray.Length)
oFileStream.Close()
Catch ex As Exception
MsgBox(ex.Message)
End Try
End Sub
Private Sub ToXML(ByVal XMLPath As String, ByVal FilePath As String)
Dim oArray() As Byte
Dim oStreamWriter As System.IO.StreamWriter
Dim oSerialiser As New System.Xml.Serialization.X
Dim oFileStream As System.IO.FileStream
Try
oFileStream = System.IO.File.Open(FilePa
ReDim oArray(oFileStream.Length - 1)
oFileStream.Read(oArray, 0, oFileStream.Length)
oFileStream.Close()
oStreamWriter = System.IO.File.CreateText(
oSerialiser.Serialize(oStr
oStreamWriter.Close()
Catch ex As Exception
MsgBox(ex.Message)
End Try
End Sub
Call the ToXML sub with the path you want to save the XML to and the file you want to create it from.
Call the FromXML sub with the path of the XML Document and the path you want to save the data to.
Will work for any file type.
ASKER
TheLearnedOne,
Why is this not advisable? I'm trying to pass a .wmf file from web-service to web-service?
rfgkev
I'll give'r a try.
Why is this not advisable? I'm trying to pass a .wmf file from web-service to web-service?
rfgkev
I'll give'r a try.
The concept is called "XML overhead", and basically is means that serializing binary data adds a lot of information which increases the file size, and reduces bandwidth. If you are looking for a scalable product, with 1000's of users, then you would tend to avoid it, and move to a strictly binary transmission.
Bob
Bob
/agree it more than doubles the file size, so binary transmission would be more resource effective, however if you are using xml web services, this is the way to do it.
ASKER
Yea, if you can come up with another way using xml webservices let me know I'll try it.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Really?
yup
ASKER
Worked great! Exactly what I was looking for
I should have taken the time to give a better explanation:)
Bob
Bob
That's what you get for being swamped with integration testing:)
Bob
Bob
ASKER
I should have asked my question at a higher also ...
Bob