Solved

.WMF to XML

Posted on 2004-08-04
13
234 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
 
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
How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

 
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

Free Trending Threat Insights Every Day

Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

Join & Write a Comment

This tutorial demonstrates one way to create an application that runs without any Forms but still has a GUI presence via an Icon in the System Tray. The magic lies in Inheriting from the ApplicationContext Class and passing that to Application.Ru…
I think the Typed DataTable and Typed DataSet are very good options when working with data, but I don't like auto-generated code. First, I create an Abstract Class for my DataTables Common Code.  This class Inherits from DataTable. Also, it can …
This video gives you a great overview about bandwidth monitoring with SNMP and WMI with our network monitoring solution PRTG Network Monitor (https://www.paessler.com/prtg). If you're looking for how to monitor bandwidth using netflow or packet s…
In this tutorial you'll learn about bandwidth monitoring with flows and packet sniffing with our network monitoring solution PRTG Network Monitor (https://www.paessler.com/prtg). If you're interested in additional methods for monitoring bandwidt…

743 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

Need Help in Real-Time?

Connect with top rated Experts

11 Experts available now in Live!

Get 1:1 Help Now