File myFile = null给出错误消息,提示不能对静态类型为'System.IO.File'的变量进行declaire,请帮助我 [英] File myFile = null gives an error tthat says can not declaire a variable of static type 'System.IO.File' please help me ou

查看:289
本文介绍了File myFile = null给出错误消息,提示不能对静态类型为'System.IO.File'的变量进行declaire,请帮助我的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.IO;
using System.Data;
using System.Data.SqlClient;
using System.Text;
using System.Configuration;
using System.Data.Sql;
using System.Media;



namespace PDF_Files
{
    public partial class DownloadFile : System.Web.UI.Page
    {

        File myFile = null;
        protected void Page_Load(object sender, EventArgs e)
        {

            Response.ContentType = "application/x-uknown";
            Response.AppendHeader("Content - Disposiotion", "atachment;filename=\"" + myFile.OriginalName + "\"");
            if (myFile != null)
            {
                Response.BinaryWrite(myFile.FileData);
            }
            else
            {
                Response.WriteFile(Path.Combine(AppConfiguration.UploadFolder, myFile.FileUrl));

            }
        }
    }
}

推荐答案

尝试一下.

try this.

File.Create("/path/myFile");




System.IO.File是静态类,因此无法实例化.
请参阅用法示例System.IO.File静态类:
Hi,

System.IO.File is a static class and, therefore, cannot be instantiated.
See sample usage System.IO.File static class:
File Class Sample




希望这可以帮助...

问候,

Algem




Hope this could help...

Regards,

Algem


朋友你好,我想你不能理解静态类的含义... ???
在那里,您尝试执行这样的代码..

请继续阅读本文以了解静态类
http://msdn.microsoft.com/en-us/library/79b3xss3 (v = vs.80).aspx [ http://msdn.microsoft.com/en-us/library/system.io. file.aspx [^ ]
Hello Friend I think You Cant Understand the Meaning of Static Class...???
there fore you try to do code like this..

please go forward through this article for static class
http://msdn.microsoft.com/en-us/library/79b3xss3(v=vs.80).aspx[^]

System.IO.File class is s Static Class you can not create a instance or object of this class you simply use that class directly..

http://msdn.microsoft.com/en-us/library/system.io.file.aspx[^]


这篇关于File myFile = null给出错误消息,提示不能对静态类型为'System.IO.File'的变量进行declaire,请帮助我的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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