当前位置:编程学习 > C#/ASP.NET >>

设置断点可运行,不设置则不能运行

我在.net中实现了ftp,可以下载文件,但是不稳定;在获取ftp文件列表的时候,设置断点以后,可以得到正确的文件列表信息,但是如果不设置断点,获得的文件列表是错误的,只能得到一部分,没有得到全部的列表信息?希望各位帮我分析一下,谢谢! --------------------编程问答-------------------- 程序跟断点有关系? 
楼主还是看看 网络配置
 帮顶 --------------------编程问答-------------------- 是不是有连接超时什么的 --------------------编程问答-------------------- 估计是连接超时了吧
设置断点的话应该效果好些 --------------------编程问答-------------------- 这些都不是原因,这些我都考虑过! --------------------编程问答-------------------- 那要看是怎么实现下载的了。

如果没有用新进程来执行ftp下载,加断时,ftp程序执行完下载后,才执行下面的语句,如果不加断点,程序运行快,直接就执行后面的程序了。 --------------------编程问答-------------------- 读一个,线程就sleep一段时间看看~~ --------------------编程问答-------------------- 还没有取完数据你就运行到下面的代码了,当然不完整了 --------------------编程问答-------------------- 确实没有新进程来执行ftp下载,那有什么解决的办法没有? --------------------编程问答-------------------- 下载的时候每下载一个停1秒就行。 --------------------编程问答--------------------  Return a string array containing the remote directory's file list.
///
public string[] getFileList(string mask)
{

if(!logined)
{
login();
}

Socket cSocket = createDataSocket();

sendCommand("NLST " + mask);

if(!(retValue == 150 || retValue == 125 || retValue == 550)) // 550 *.*: No such file or directory.
{
LogInfo += (reply.Substring(4) + ";");
throw new IOException(reply.Substring(4));
}

if(retValue == 550)
{
string[] tmp550 =new string[1];
tmp550[0] ="";
return tmp550;
}
mes = "";

while(true)
{

int bytes = cSocket.Receive(buffer, buffer.Length, 0);
mes += ASCII.GetString(buffer, 0, bytes);

if(bytes < buffer.Length)
{
break;
}
}

char[] seperator = {'\n'};
string[] mess = mes.Split(seperator);

cSocket.Close();

readReply();

if(retValue != 226)
{
LogInfo += (reply.Substring(4) + ";");
throw new IOException(reply.Substring(4));
}
return mess;

}

///
/// Return a string array containing the remote directory's file list.
///
public string getDirectory()
{

if(!logined)
{
login();
}

Socket cSocket = createDataSocket();

sendCommand("LIST");

if(!(retValue == 150 || retValue == 125))
{
LogInfo += (reply.Substring(4) + ";");
throw new IOException(reply.Substring(4));
}

mes = "";

while(true)
{

int bytes = cSocket.Receive(buffer, buffer.Length, 0);
mes += ASCII.GetString(buffer, 0, bytes);

if(bytes < buffer.Length)
{
break;
}
}

char[] seperator = {'\n'};
string[] mess = mes.Split(seperator);

//cSocket.Close();

readReply();

if(retValue != 226)
{
LogInfo += (reply.Substring(4) + ";");
throw new IOException(reply.Substring(4));
}
if(mess[2] == "")
return "";

mes = mess[2].Substring(55,mess[2].Length-56);
return mes;

} --------------------编程问答-------------------- 这是获取ftp文件列表的代码,如果不设置断点的话,红色部分的bytes返回值不完整,我觉得五楼的原因是合理的,可是怎么解决?请大家帮吗啊!
--------------------编程问答-------------------- 用线程来试试 --------------------编程问答-------------------- 用线程来试试 --------------------编程问答-------------------- 解决了,谢谢大家的帮忙哈!
补充:.NET技术 ,  C#
CopyRight © 2012 站长网 编程知识问答 www.zzzyk.com All Rights Reserved
部份技术文章来自网络,