我周围100个远程服务器及以下的,我怎么想一些文件 从我的电脑复制到所有这些远程服务器中有,但我想要做一些检查文件复制到远程服务器检查
1-检查如果到远程服务器连接可用如果没有的话去隔壁办公室
2用户交互
A-我试图颜色选择行的datagridview1
让用户知道whcih办公室的进展是现在和alos在datagridview2
同样的事情,让用户知道在哪个文件的进展是现在在特定的办公室,但开始发送文件后,界面冻结,没有互动发生什么?
b-如何成功完成绿色成品办公室排如果成功?
更新
我用线程解决形式冻结这样的反馈将返回到用户 ,但问题没有得到解决,仍然会发生并没有什么变化,请我应该怎么办???
public void PatchUpdates()
{
try
{
foreach (DataGridViewRow OfficeListRow in DGV_OfficeList.Rows)
{
string OfficeIPAddress = OfficeListRow.Cells[2].Value.ToString();
foreach (DataGridViewRow FileListRow in DGV_FileList.Rows)
{
string SoruceFileNamePath = FileListRow.Cells[4].Value.ToString();
string DestinationFileNamePath = @"\\" + OfficeIPAddress + @"\usb1_1\test\" + Path.GetFileName(SoruceFileNamePath);
Thread foregroundthread = new Thread(() => CheckOffice(OfficeIPAddress));
foregroundthread.Start();
//check if connection to remote server is available
if (CheckOffice(OfficeIPAddress) == 1)
{
DGV_OfficeList[3, DGV_OfficeList.CurrentCell.RowIndex].Value = "Connected";
//file.copy(sorucefilenamepath, destinationfilenamepath, true); //copy files...
}
else if (CheckOffice(OfficeIPAddress) == 0)
{
DGV_OfficeList[3, DGV_OfficeList.CurrentCell.RowIndex].Value = "disconnected";
break;
}
}
}
}
catch (Exception ex)
{
MessageBox.Show(ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
}
}
检查连接方法
public int CheckOffice(string _ipAddress)
{
int timeout = 120;
string data = "PingTestData";
byte[] buffer = Encoding.ASCII.GetBytes(data);
Ping PingSender = new Ping();
PingOptions options = new PingOptions();
options.DontFragment = true;
PingReply reply = PingSender.Send(_ipAddress, timeout, buffer, options);
if (reply.Status == IPStatus.Success)
{
return 1;
}
else
{
return 0;
}
}
我不得不使用ping类 现在我有问题,在DataGridView中返回的结果是不正确的更新我的职务与检查大多数时间,有时整个电脑冻结并重新启动...是否有任何建议关于该检查reomte服务器检查部分? – sam
@Sam:数据网格视图中的结果不正确 - >在foreach循环中运行不会更改由ping响应更新的gridview的当前单元格 –
@Sam PC冻结并重新启动 - >您正在使用哪个操作系统?这应该不会发生在运行Windows NT 4或更高版本的系统上的正常应用程序代码。 –