views:

1764

answers:

3

Does anyone know if/how I can convert a binary formatted Mac OS X plist file to a plain XML string in C#?

I know there are some plist editors for Windows available that says they support binary formatted plist files, but I need to do this inline in my own application.

+1  A: 

a quick google reveals plutil.pl, but that will only work if perl is installed (which I'm fairly certain is not the default in windows)

cobbal
I found that one too, but I don't want to add perl as yet another requirement to my application. The best would be to be able to use the encodings in the framework, but I start to doubt that they are able to convert this format.
Geir-Tore Lindsve
I found an executable version of this utility. In my code, I write the binary plist to a file, use plutil.exe to convert it to plain XML and then read in the result file.
Geir-Tore Lindsve
A: 

If you want to do the conversion in code on the OS X side, this previous SO question has your answer. Alternatively, you can use the plutil command line utility on OS X to convert between binary and XML property lists.

Barry Wark
Thanks, but I need to be able to read a binary formatted plist at runtime in my .NET application. The reason is that CoreData stores metadata in this format and I have a cross platform application that needs to read the same data file as the mac version.We might have to pull it off by duplicating the metadata in a separate table though, as I have yet to find a reliable way of doing this
Geir-Tore Lindsve
+1  A: 

I haven't tried any of the solutions below, and I know you were looking for C# but...

This page has a binary plist parser implemented in java:
http://www.java2s.com/Open-Source/Java/Swing/JIDE-Common/com/jidesoft/plaf/aqua/BinaryPListParser.java.htm

The Java Quaqua project (https://quaqua.dev.java.net/) uses a binary plist java parser. You can see the java doc here http://www.randelshofer.ch/quaqua/javadoc/ch/randelshofer/quaqua/util/BinaryPListParser.html

facildelembrar
Thanks for the link. Maybe it can be ported to C#
Geir-Tore Lindsve