Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/csharp/336.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# &引用;参数无效";System.Drawing.Image.FromStream()方法的异常_C#_Asp.net_System.drawing - Fatal编程技术网

C# &引用;参数无效";System.Drawing.Image.FromStream()方法的异常

C# &引用;参数无效";System.Drawing.Image.FromStream()方法的异常,c#,asp.net,system.drawing,C#,Asp.net,System.drawing,我在我的网站上使用Image.FromStream方法时遇到了困难。下面的代码在我的电脑上运行得很好。但是当我把它上传到测试服务器时,它总是给我“Parameter not valid”异常 if (!afuImageFile.IsUploading && afuImageFile.HasFile) { System.Drawing.Image imgFile = System.Drawing.Image.FromStream(afuImageFile.FileConte

我在我的网站上使用Image.FromStream方法时遇到了困难。下面的代码在我的电脑上运行得很好。但是当我把它上传到测试服务器时,它总是给我“Parameter not valid”异常

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

afuImageFile
是Ajax工具包中的
AsynFileUploader
控件
afuImageFile.FileContent
是一个
HttpInputStream
。我想我需要向某个文件夹添加一些权限。有人能帮我吗?

请确保您的
文件内容流的位置设置为0

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

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


请参阅以检查其他重载。

听起来与此问题类似。
System.Drawing.Image imgFile = System.Drawing.Image.FromStream(afuImageFile.FileContent, true, false);