本文介绍了Asp.net循环显示输出的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我希望在Ping IP时显示输出。但是当循环完成时显示输出。
我尝试过:
i want to display output when its Ping IP.but its displaying when loop complete.
What I have tried:
public void getpasofflinedetails()
{
Ping ping = new Ping();
List<string> Results = new List<string>();
string cctns_offline_DBConnectionString = ConfigurationManager.ConnectionStrings["constr"].ConnectionString;
string[] filePaths = Directory.GetFiles(ConfigurationManager.AppSettings["filePath"].ToString(), "*.properties",
SearchOption.TopDirectoryOnly);
foreach (string fileName in filePaths)
{
// Read a text file using StreamReader
using (System.IO.StreamReader sr = new System.IO.StreamReader(fileName))
{
String line;
while ((line = sr.ReadLine()) != null)
{
if (line.StartsWith("db.url"))
{
string[] PS_CD = fileName.Split(new[] { "\\", ".", "_" }, StringSplitOptions.None);
if (PS_CD.Length > 5)
{
string[] ip_address = line.Split(new[] { ";", "//", "/", ":" }, StringSplitOptions.None);
PingReply pingreply = ping.Send(ip_address[3].ToString());
Response.writeline(String.Format("PS_CD:{0} <br/>Request:{1} ", PS_CD[4].ToString(), pingreply.Status.ToString()));
}
}
}
}
}
推荐答案
这篇关于Asp.net循环显示输出的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!