.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?
LVL 5
thenrichAsked:
Who is Participating?
 
rfgkevConnect With a Mentor Commented:
there is also an easier way,

To send the file, just add a Byte Array parameter to your webservice, and pass it a byte array
To recieve the file, just return a Byte Array from your web service.

All the conversion will be taken care of for you :)
0
 
Bob LearnedCommented:
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
0
 
rfgkevCommented:
     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.
0
Get your problem seen by more experts

Be seen. Boost your question’s priority for more expert views and faster solutions

 
thenrichAuthor Commented:
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.
0
 
Bob LearnedCommented:
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
0
 
rfgkevCommented:
/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.
0
 
thenrichAuthor Commented:
Yea, if you can come up with another way using xml webservices let me know I'll try it.
0
 
thenrichAuthor Commented:
Really?
0
 
rfgkevCommented:
yup
0
 
thenrichAuthor Commented:
Worked great! Exactly what I was looking for
0
 
Bob LearnedCommented:
I should have taken the time to give a better explanation:)

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

Bob
0
 
thenrichAuthor Commented:
I should have asked my question at a higher also ...
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.