Link to home
Start Free TrialLog in
Avatar of thenrich
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?
Avatar of Bob Learned
Bob Learned
Flag of United States of America image

Why do you want to do this?  What are you trying to accomplish?  What you describe is not advisable, and there might be a better solution.

Bob
Avatar of rfgkev
rfgkev

     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.XmlSerializer(GetType(Byte()))
            Dim oFileStream As System.IO.FileStream

            Try
                  oStreamReader = System.IO.File.OpenText(XMLPath)
                  oArray = oSerialiser.Deserialize(oStreamReader)
                  oStreamReader.Close()

                  oFileStream = System.IO.File.Open(FilePath, 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.XmlSerializer(GetType(Byte()))
            Dim oFileStream As System.IO.FileStream

            Try
                  oFileStream = System.IO.File.Open(FilePath, IO.FileMode.Open)
                  ReDim oArray(oFileStream.Length - 1)
                  oFileStream.Read(oArray, 0, oFileStream.Length)
                  oFileStream.Close()

                  oStreamWriter = System.IO.File.CreateText(XMLPath)
                  oSerialiser.Serialize(oStreamWriter, 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.
Avatar of thenrich

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.
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
/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.
Yea, if you can come up with another way using xml webservices let me know I'll try it.
ASKER CERTIFIED SOLUTION
Avatar of rfgkev
rfgkev

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Really?
yup
Worked great! Exactly what I was looking for
I should have taken the time to give a better explanation:)

Bob
That's what you get for being swamped with integration testing:)

Bob
I should have asked my question at a higher also ...