【问题标题】:"Parameter is not valid" exception from System.Drawing.Image.FromStream() methodSystem.Drawing.Image.FromStream() 方法的“参数无效”异常
【发布时间】:2011-04-04 22:51:26
【问题描述】:

我在我的网站中使用 Image.FromStream 方法时遇到了困难。下面的代码在我的电脑上完美运行。但是当我将它上传到测试服务器时,它总是给我“参数无效”异常。

if (!afuImageFile.IsUploading && afuImageFile.HasFile)
{
    System.Drawing.Image imgFile = System.Drawing.Image.FromStream(afuImageFile.FileContent);
}

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

【问题讨论】:

标签: c# asp.net system.drawing


【解决方案1】:

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

否则,您可能希望通过更改调用来停用图像验证:

System.Drawing.Image imgFile = System.Drawing.Image.FromStream(afuImageFile.FileContent);

到:

System.Drawing.Image imgFile = System.Drawing.Image.FromStream(afuImageFile.FileContent, true, false);

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

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2015-04-25
    • 2014-01-25
    • 1970-01-01
    • 1970-01-01
    • 2015-09-28
    • 1970-01-01
    • 2011-07-17
    • 2012-02-20
    相关资源
    最近更新 更多