Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/asp.net/31.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C# 从base64保存图像_C#_Asp.net - Fatal编程技术网

C# 从base64保存图像

C# 从base64保存图像,c#,asp.net,C#,Asp.net,我使用下面的代码在asp.net中用C#保存图像。保存时没有错误,但我无法在函数中指定路径 public Image Base64ToImage(string base64String) { // Convert Base64 String to byte[] byte[] imageBytes = Convert.FromBase64String(base64String); MemoryStream ms = new MemoryStream(

我使用下面的代码在asp.net中用C#保存图像。保存时没有错误,但我无法在函数中指定路径

public Image Base64ToImage(string base64String)
{
        // Convert Base64 String to byte[]
        byte[] imageBytes = Convert.FromBase64String(base64String);
        MemoryStream ms = new MemoryStream(imageBytes, 0,
          imageBytes.Length);

        // Convert byte[] to Image
        ms.Write(imageBytes, 0, imageBytes.Length);
        Image image = Image.FromStream(ms, true);
        image.Save("test", ImageFormat.Png);
        //image.Save("test.png");
        return image;
  }

如果我使用
server.mappath
放置物理路径,它将生成一个错误GDI异常。我做错了什么

可能是位置访问权限?请粘贴解决我问题的确切例外情况???@Magnus。