日期:2014-05-17  浏览次数:20538 次

System.Web.HttpContext.Current.Server.MapPath("a.txt").ToString(); 报错“未将对象引用设置到对象的实例。”
在cs类文件里写:
System.Web.HttpContext.Current.Server.MapPath("a.txt").ToString();  
报错“未将对象引用设置到对象的实例。”
我不知道为什么,


------解决方案--------------------
判断一下a.txt是否存在
------解决方案--------------------
代码贴全
------解决方案--------------------
你的1.txt是否存在于指定目录?
FILE.EXIST(1.TXT)他是BOOL型的 你看下返回值
------解决方案--------------------
探讨
引用:
你的1.txt是否存在于指定目录?
FILE.EXIST(1.TXT)他是BOOL型的 你看下返回值



C# code//此处写你自己想执行的任务
string path = System.Web.HttpContext.Current.Server.MapPath("a.txt").ToString();
//string path = "D:\\web\\code\\定时\\a.txt";
zhqlzzf.FileObj.WriteFile(path, DateTime.Now.ToString());


上面是错…