With Entity Framework, while using Migration files with code-first, it generates .resx
files (xml), which contains a data field named Target
:
<data name="Target" xml:space="preserve">
<value>H4sIAAAAAAAEAO ... ICAA==</value>
</data>
In which format is that field? The ==
at the end of the data make think it is base64, but when decoded, it looked like it is binary data. Anyone know the structure/format of the data?
It is an edmx/xml file that has been gzipped and then base64 encoded. The following application will print out the xml for a given .resx file.
using System;
using System.Collections;
using System.IO;
using System.IO.Compression;
using System.Resources;
using System.Xml.Linq;
namespace ResxReader
{
class Program
{
private const string ResxFilename = @"full path to your .resx file";
public static void Main()
{
var reader = new ResXResourceReader(ResxFilename);
IDictionaryEnumerator resources = reader.GetEnumerator();
while (resources.MoveNext())
{
if ("Target".Equals(resources.Key))
{
XDocument target = Decompress(Convert.FromBase64String(resources.Value.ToString()));
Console.Write(target);
}
}
}
public static XDocument Decompress(byte[] bytes)
{
using (var memoryStream = new MemoryStream(bytes))
{
using (var gzipStream = new GZipStream(memoryStream, CompressionMode.Decompress))
{
return XDocument.Load(gzipStream);
}
}
}
}
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With