极度郁闷中,,,,,,,,高人进来~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
代码如下:
public class Ftp
{
#region 私有成员
//-------------------------------------------------------------------------------
1.
//private string host = "";
//private string user = "";
//private string password = "";
//private int port = 21;
//private string url = "";
//private string destPath = "";
//-----------------------------------------------------------------------------
2.
private string host;
private string user;
private string password;
private int port = 21;
private string url;
private string destPath;
//-------------------------------------------------------------------------------
private static MessageCallBackFunc lpMsg = null;
private static PacketRecvCallBackFunc lpPackRecv = null;
private static FileCompleteCallBackFunc lpFileComp = null;
#endregion
#region 回调函数
public delegate void MessageCallBackFunc(string msg);
public delegate void PacketRecvCallBackFunc(string file, int totalBytes, int bytesRecved);
public delegate void FileCompleteCallBackFunc(string file);
#endregion
#region API
[DllImport("FTP.dll", EntryPoint="FtpDownload",CharSet=CharSet.Ansi,CallingConvention=CallingConvention.StdCall)]
private static extern void _Download(string host, string user, string pass,
int nPort, string url, string locaFile,
MessageCallBackFunc lpMsg, PacketRecvCallBackFunc lpPackRecv,
FileCompleteCallBackFunc lpFileComp);
#endregion
#region 属性
public String Host
{
get
{
return this.host;
}
set
{
if (value.Length == 0)
throw new Exception("Host空参数异常");
this.host = value;
}
}
public String UserID
{
get
{
return this.user;
}
set
{
if (value.Length == 0)
throw new Exception("UserID空参数异常");
this.user = value;
}
}
public String Password
{
get
{
return this.password;
}
set
{
if (value.Length == 0)
throw new Exception("Password空参数异常");
this.password = value;
}
}
public int Port
{
get
{
return this.port;
}
set
{
if (value == 0)
this.port = 21;
else
this.port = value;
}
}
public string DownFile
{
get
{
return this.url;
}
set
{
if (value.Length == 0)
throw new Exception("DownFile空参数异常");
this.url = value;
}
}
public string DestPath
{
get
{
return this.destPath;
}
set
{
if (value.Length == 0)
throw new Exception("DestPath空参数异常");
this.destPath = value;
}
}
#endregion
#region 构造及析构
public Ftp(MessageCallBackFunc lpMsg, PacketRecvCallBackFunc lpPackRecv, FileCompleteCallBackFunc lpFileComp)
{
if (lpMsg != null)
lpMsg = lpMsg;
if (lpPackRecv != null)
lpPackRecv = lpPackRecv;
if (lpFileComp != null)
lpFileComp = lpFileComp;
}
~Ftp()
{
}
#endregion
#region 方法申明
public void DownloadEx(string url, string localFile)
{
this.url = url;
Ftp._Download(this.host, this.user, this.password, this.port, this.url, localFile,
lpMsg, lpPackRecv, lpFileComp); <=============此处出现"未将对象引用设置为对象的实例"异常
}
public void DownloadEx()
{
string shortname = this.url.Substring(this.url.LastIndexOf("/") + 1,
this.url.Length - this.url.LastIndexOf("/") - 1);
Ftp._Download(this.host, this.user, this.password, this.port, this.url, this.destPath + "\\" + shortname,
lpMsg, lpPackRecv, lpFileComp);
}
}
如果将上面1处注释的代码替换为2外的代码,则在_Download调用处出现未将对象引用设置为对象实例的异常,如果使用2处的代码,则_Download有时会出现同样的异常,但却没有规律,,,,,极度郁闷中~~~~~
代码1处和2处的差别只是加了成员变量的初始化,为啥就这么一加就运行效果就那么大的差别,哪位高人指点一二,,,,,,,偶快疯掉了~~~~~~~~~~~~
public class Ftp
{
#region 私有成员
//-------------------------------------------------------------------------------
1.
//private string host = "";
//private string user = "";
//private string password = "";
//private int port = 21;
//private string url = "";
//private string destPath = "";
//-----------------------------------------------------------------------------
2.
private string host;
private string user;
private string password;
private int port = 21;
private string url;
private string destPath;
//-------------------------------------------------------------------------------
private static MessageCallBackFunc lpMsg = null;
private static PacketRecvCallBackFunc lpPackRecv = null;
private static FileCompleteCallBackFunc lpFileComp = null;
#endregion
#region 回调函数
public delegate void MessageCallBackFunc(string msg);
public delegate void PacketRecvCallBackFunc(string file, int totalBytes, int bytesRecved);
public delegate void FileCompleteCallBackFunc(string file);
#endregion
#region API
[DllImport("FTP.dll", EntryPoint="FtpDownload",CharSet=CharSet.Ansi,CallingConvention=CallingConvention.StdCall)]
private static extern void _Download(string host, string user, string pass,
int nPort, string url, string locaFile,
MessageCallBackFunc lpMsg, PacketRecvCallBackFunc lpPackRecv,
FileCompleteCallBackFunc lpFileComp);
#endregion
#region 属性
public String Host
{
get
{
return this.host;
}
set
{
if (value.Length == 0)
throw new Exception("Host空参数异常");
this.host = value;
}
}
public String UserID
{
get
{
return this.user;
}
set
{
if (value.Length == 0)
throw new Exception("UserID空参数异常");
this.user = value;
}
}
public String Password
{
get
{
return this.password;
}
set
{
if (value.Length == 0)
throw new Exception("Password空参数异常");
this.password = value;
}
}
public int Port
{
get
{
return this.port;
}
set
{
if (value == 0)
this.port = 21;
else
this.port = value;
}
}
public string DownFile
{
get
{
return this.url;
}
set
{
if (value.Length == 0)
throw new Exception("DownFile空参数异常");
this.url = value;
}
}
public string DestPath
{
get
{
return this.destPath;
}
set
{
if (value.Length == 0)
throw new Exception("DestPath空参数异常");
this.destPath = value;
}
}
#endregion
#region 构造及析构
public Ftp(MessageCallBackFunc lpMsg, PacketRecvCallBackFunc lpPackRecv, FileCompleteCallBackFunc lpFileComp)
{
if (lpMsg != null)
lpMsg = lpMsg;
if (lpPackRecv != null)
lpPackRecv = lpPackRecv;
if (lpFileComp != null)
lpFileComp = lpFileComp;
}
~Ftp()
{
}
#endregion
#region 方法申明
public void DownloadEx(string url, string localFile)
{
this.url = url;
Ftp._Download(this.host, this.user, this.password, this.port, this.url, localFile,
lpMsg, lpPackRecv, lpFileComp); <=============此处出现"未将对象引用设置为对象的实例"异常
}
public void DownloadEx()
{
string shortname = this.url.Substring(this.url.LastIndexOf("/") + 1,
this.url.Length - this.url.LastIndexOf("/") - 1);
Ftp._Download(this.host, this.user, this.password, this.port, this.url, this.destPath + "\\" + shortname,
lpMsg, lpPackRecv, lpFileComp);
}
}
如果将上面1处注释的代码替换为2外的代码,则在_Download调用处出现未将对象引用设置为对象实例的异常,如果使用2处的代码,则_Download有时会出现同样的异常,但却没有规律,,,,,极度郁闷中~~~~~
代码1处和2处的差别只是加了成员变量的初始化,为啥就这么一加就运行效果就那么大的差别,哪位高人指点一二,,,,,,,偶快疯掉了~~~~~~~~~~~~
...全文
相关推荐
郁闷发泄专家2007
虽然《郁闷发泄专家2007》在帮助人们应对日常生活中的小郁闷方面具有一定的效果,但它仍然是一种辅助手段。当个体面临严重或长期的压力时,依然需要依靠专业的心理咨询或治疗来解决问题。
郁闷发泄者
【标题】:“郁闷发泄者”实际上是一款专为那些感到无聊或者需要释放压力的人设计的软件集合。
控制屏幕郁闷发泄专家
控制屏幕郁闷发泄专家控制屏幕郁闷发泄专家
谈谈职场上你最郁闷什么.doc
总之,职场郁闷是多种因素共同作用的结果。个人、企业乃至社会都应该关注这一问题,并采取相应的措施来缓解职场的郁闷情绪。对于个人来说,培养良好的心理素质和人际关系处理能力是应对职场挑战的重要手段。
PJBlog2 郁闷的圣诞
郁闷的圣诞"这个主题是PJBlog模板的一个实例,它可能包含以下内容:1.


