C# 不使用System.Drawing将图元文件图像转换为字节数组

C# 不使用System.Drawing将图元文件图像转换为字节数组,c#,asp.net,azure,system.drawing,C#,Asp.net,Azure,System.drawing,我需要在不使用System.Drawing的情况下将wmf文件转换为字节数组。我无法使用System.Drawing的原因是Azure环境不支持GDI+的某些功能。代码可以在本地环境中执行,但部署到服务器时无法工作。为了利用GDI+,我不得不将应用程序外部的调整大小逻辑移到Azure VM上。我们必须为遗留应用程序支持wmf文件 部署到Azure web应用程序时,以下操作将失败 byte[] imgArr; using (var ms = new MemoryStream()) { s

我需要在不使用System.Drawing的情况下将wmf文件转换为字节数组。我无法使用System.Drawing的原因是Azure环境不支持GDI+的某些功能。代码可以在本地环境中执行,但部署到服务器时无法工作。为了利用GDI+,我不得不将应用程序外部的调整大小逻辑移到Azure VM上。我们必须为遗留应用程序支持wmf文件

部署到Azure web应用程序时,以下操作将失败

byte[] imgArr;
using (var ms = new MemoryStream())
{
    sourceImage.Save(ms, ImageFormat.Png);
    imgArr = ms.ToArray();
}


两者都使用System.Drawing库,后者使用GDI+。是否有其他方法将Windows图元文件获取到字节数组?

请尝试使用以下代码,它在我这方面有效

   FileInfo fileInfo = new FileInfo(path); // the path should be accessed in the azure portal

   // The byte[] to save the imgArr in
   byte[] imgArr= new byte[fileInfo.Length];

   // Load a filestream and put its content into the byte[]

   using (FileStream fs = fileInfo.OpenRead())
   {
       fs.Read(imgArr, 0, imgArr.Length);
   }

请尝试使用下面的代码,它在我这边起作用

   FileInfo fileInfo = new FileInfo(path); // the path should be accessed in the azure portal

   // The byte[] to save the imgArr in
   byte[] imgArr= new byte[fileInfo.Length];

   // Load a filestream and put its content into the byte[]

   using (FileStream fs = fileInfo.OpenRead())
   {
       fs.Read(imgArr, 0, imgArr.Length);
   }