System.Drawing.Image.FromStream()方法中的"参数无效"异常

Leo*_*n.S 6 c# asp.net system.drawing

我在网站上使用Image.FromStream方法很难.以下代码在我的计算机上运行良好.但是当我将它上传到测试服务器时,它总是给我"参数无效"异常.

if (!afuImageFile.IsUploading && afuImageFile.HasFile)
{
    System.Drawing.Image imgFile = System.Drawing.Image.FromStream(afuImageFile.FileContent);
}
Run Code Online (Sandbox Code Playgroud)

afuImageFileAsynFileUploaderAjax工具包中的一个控件.afuImageFile.FileContent是一个HttpInputStream.我想我需要为某个文件夹添加一些权限.谁能帮我?

Max*_*ler 2

请确保您的FileContent流的位置设置为 0。

否则,您可能需要通过更改以下调用来停用图像验证:

System.Drawing.Image imgFile = System.Drawing.Image.FromStream(afuImageFile.FileContent);
Run Code Online (Sandbox Code Playgroud)

到:

System.Drawing.Image imgFile = System.Drawing.Image.FromStream(afuImageFile.FileContent, true, false);
Run Code Online (Sandbox Code Playgroud)

请参阅Image.FromStream检查其他过载。