为什么Web应用程序代码显示错误,因为参数无效?而Windows窗体应用程序正确执行。 [英] Why Web application code is showing error as Parameter is not Valid? while windows form application executes correctly.

查看:134
本文介绍了为什么Web应用程序代码显示错误,因为参数无效?而Windows窗体应用程序正确执行。的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

IN WINDOWS FORM APPLICATION



IN WINDOWS FORM APPLICATION

private void button1_Click(object sender, EventArgs e)
       {
           DialogResult dr = openFileDialog1.ShowDialog();
           if (dr == DialogResult.OK)
           {
               string filename = openFileDialog1.FileName;
               Bitmap bt = new Bitmap(filename);
               int x= bt.Width;



}



在WEB应用程序中




}

IN WEB APPLICATION

protected void Button1_Click(object sender, EventArgs e)
   {
       if (FileUpload1.HasFile)
       {
           string filename = FileUpload1.PostedFile.FileName;
           Bitmap bt = new Bitmap(filename); <------Parameter is not valid
            int x = bt.Width;



}



我想获得在web应用程序中使用fileupload控件上传的图像宽度Windows窗体应用程序中的OpenFileDialog ..

我使用相同的逻辑获取Windows窗体中的大小...但是,当基于Web实现相同的逻辑时,它会出现错误'参数无效'...

Plz解释并给出确切的代码以获得宽度....

谢谢。


}

I want to get Width of image which is uploaded by using fileupload control in web application and OpenFileDialog in windows form app..
I get the size in windows form using the same logic ...but, when the same logic is implemented in web based it gives an error 'Parameters is not valid'...
Plz explain and give the exact code to get width....
Thanks.

推荐答案

您好,



这可能是文件权限问题,您需要确保您网站的IUSR帐户具有对图像文件的读取权限。



要做到这一点 -

R-单击文件,属性,选择安全选项卡 - 您将拥有一个用户列表谁有权访问该文件。快速检查是添加具有读取权限的Everyone。要将它锁定到您的ASP.Net实例,只需启动IIS管理器,然后单击您的应用程序池,身份就是您的应用程序运行的用户。



参考: http://stackoverflow.com/questions/7636805/参数是无效的错误 - 创建新位图时的错误 [ ^ ]


这篇关于为什么Web应用程序代码显示错误,因为参数无效?而Windows窗体应用程序正确执行。的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆