大家好,我在一个DrawGraph类中写一个画图程序,代码如下:
string imgStorePath = "\\Image\\" + userID + "\\Weight_" + DateTime.Now.ToString("yyyyMMddHHmmss") + ".jpg";
btp.Save(imgStorePath);我用跟踪测试时,发现执行到Save时出错,提示“未将对象引用设置到对象的实例”,但imgStorePath是有正确的值。是不能在类中这样处理,还是什么原因?100分求救,高手指点下,多谢。
string imgStorePath = "\\Image\\" + userID + "\\Weight_" + DateTime.Now.ToString("yyyyMMddHHmmss") + ".jpg";
btp.Save(imgStorePath);我用跟踪测试时,发现执行到Save时出错,提示“未将对象引用设置到对象的实例”,但imgStorePath是有正确的值。是不能在类中这样处理,还是什么原因?100分求救,高手指点下,多谢。
必须绝对path。
论坛签名======================================================================success1000:你好!
截至 2011-10-28 17:45:38 前:
你已发帖 16 个, 未结贴 1 个;
结贴率为: 93.75%
当您的问题得到解答后请及时结贴.
http://topic.csdn.net/u/20090501/15/7548d251-aec2-4975-a9bf-ca09a5551ba5.html
http://topic.csdn.net/u/20100428/09/BC9E0908-F250-42A6-8765-B50A82FE186A.html
http://topic.csdn.net/u/20100626/09/f35a4763-4b59-49c3-8061-d48fdbc29561.html如何给分和结贴?
http://community.csdn.net/Help/HelpCenter.htm#结帖如何给自己的回帖中也加上签名?
http://blog.csdn.net/q107770540/archive/2011/03/15/6250007.aspx
/// 根据从数据库中提取出来的文件路径,分离出在客户端头像的路径
/// </summary>
/// <param name="fileName">数据库中提取出来的文件路径</param>
/// <param name="faceFlag">是否进入客户端头像目录下</param>
/// <returns>faceFalg为True时,返回头像目录下的头像全路径,当faceFalg为False时,返回用户ID目录下的头像全路径 </returns>
public string getImgPath(string fileName, bool faceFlag)
{
int place;
string comPath = Application.StartupPath;
for (int i = 0; i < 2; i++)
{
place = comPath.LastIndexOf("\\");
comPath = comPath.Remove(place);
}
if (!faceFlag)
{
if (Directory.Exists(comPath + @"\\" + myInfo.Key.ToString()))
{
comPath = comPath + @"\\" + myInfo.Key.ToString() + fileName;
}
else
{
Directory.CreateDirectory(comPath + @"\\" + myInfo.Key.ToString());
comPath = comPath + @"\\" + myInfo.Key.ToString() + fileName;
}
}
else if (faceFlag)
{
comPath = comPath + @"\NEWFACE\" + fileName;
}
return comPath;
}
if (!Directory.Exists(sPath))
{
Directory.CreateDirectory(sPath);
}
string imgStorePath =sPath+\\Weight_" + DateTime.Now.ToString("yyyyMMddHHmmss") + ".jpg";
btp.Save(imgStorePath);
//获取跟目录下面的images文件夹,你得用到这个方法Server.MapPath
private string fullpath = HttpContext.Current.Server.MapPath("~/images/");
string fileName = wCacheRp.GetRandomStr(8) + fileExtension;
imgname.Text = fileName;
string fn = Server.MapPath(Request.ApplicationPath) + "\\icon\\" + fileName;
imgUp.SaveAs(fn);