Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people, just like you, are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
Solved

.WMF to XML

Posted on 2004-08-04
13
238 Views
Last Modified: 2010-04-23
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?
0
Comment
Question by:thenrich
  • 5
  • 4
  • 4
13 Comments
 
LVL 96

Expert Comment

by:Bob Learned
ID: 11722434
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
 
LVL 8

Expert Comment

by:rfgkev
ID: 11724130
     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
 
LVL 5

Author Comment

by:thenrich
ID: 11725267
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
Free Tool: Postgres Monitoring System

A PHP and Perl based system to collect and display usage statistics from PostgreSQL databases.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

 
LVL 96

Expert Comment

by:Bob Learned
ID: 11725379
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
 
LVL 8

Expert Comment

by:rfgkev
ID: 11725419
/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
 
LVL 5

Author Comment

by:thenrich
ID: 11725519
Yea, if you can come up with another way using xml webservices let me know I'll try it.
0
 
LVL 8

Accepted Solution

by:
rfgkev earned 125 total points
ID: 11725686
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
 
LVL 5

Author Comment

by:thenrich
ID: 11725765
Really?
0
 
LVL 8

Expert Comment

by:rfgkev
ID: 11725823
yup
0
 
LVL 5

Author Comment

by:thenrich
ID: 11726156
Worked great! Exactly what I was looking for
0
 
LVL 96

Expert Comment

by:Bob Learned
ID: 11726168
I should have taken the time to give a better explanation:)

Bob
0
 
LVL 96

Expert Comment

by:Bob Learned
ID: 11726172
That's what you get for being swamped with integration testing:)

Bob
0
 
LVL 5

Author Comment

by:thenrich
ID: 11726183
I should have asked my question at a higher also ...
0

Featured Post

Announcing the Most Valuable Experts of 2016

MVEs are more concerned with the satisfaction of those they help than with the considerable points they can earn. They are the types of people you feel privileged to call colleagues. Join us in honoring this amazing group of Experts.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This article explains how to create and use a custom WaterMark textbox class.  The custom WaterMark textbox class allows you to set the WaterMark Background Color and WaterMark text at design time.   IMAGE OF WATERMARKS STEPS Create VB …
Introduction As chip makers focus on adding processor cores over increasing clock speed, developers need to utilize the features of modern CPUs.  One of the ways we can do this is by implementing parallel algorithms in our software.   One recent…
Microsoft Active Directory, the widely used IT infrastructure, is known for its high risk of credential theft. The best way to test your Active Directory’s vulnerabilities to pass-the-ticket, pass-the-hash, privilege escalation, and malware attacks …
Nobody understands Phishing better than an anti-spam company. That’s why we are providing Phishing Awareness Training to our customers. According to a report by Verizon, only 3% of targeted users report malicious emails to management. With compan…

829 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question