Solved

.WMF to XML

Posted on 2004-08-04
13
237 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
Master Your Team's Linux and Cloud Stack

Come see why top tech companies like Mailchimp and Media Temple use Linux Academy to build their employee training programs.

 
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

Optimizing Cloud Backup for Low Bandwidth

With cloud storage prices going down a growing number of SMBs start to use it for backup storage. Unfortunately, business data volume rarely fits the average Internet speed. This article provides an overview of main Internet speed challenges and reveals backup best practices.

Question has a verified solution.

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

Suggested Solutions

Article by: jpaulino
XML Literals are a great way to handle XML files and the community doesn’t use it as much as it should.  An XML Literal is like a String (http://msdn.microsoft.com/en-us/library/system.string.aspx) Literal, only instead of starting and ending with w…
Creating an analog clock UserControl seems fairly straight forward.  It is, after all, essentially just a circle with several lines in it!  Two common approaches for rendering an analog clock typically involve either manually calculating points with…
Two types of users will appreciate AOMEI Backupper Pro: 1 - Those with PCIe drives (and haven't found cloning software that works on them). 2 - Those who want a fast clone of their boot drive (no re-boots needed) and it can clone your drive wh…
This video shows how to use Hyena, from SystemTools Software, to bulk import 100 user accounts from an external text file. View in 1080p for best video quality.

773 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