我有下一个问题:当我尝试在SFTP服务器上复制文件时,没有任何反应。我没有得到任何错误或异常,只是没有 在此列出:
using System;
using System.IO;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Tamir.SharpSsh;
using Tamir.Streams;
using System.Threading;
class Program
{
static void Main(string[] args)
{
string strHost = "[host]";
string strUserName = "[username]";
int nPort = 22;
string strPwd = "[pass]";
SshTransferProtocolBase sshCp;
sshCp = new Sftp(strHost, strUserName);
sshCp.Password = strPwd;
Console.Write("Connecting...");
try
{
sshCp.Connect(nPort);
}
catch (Exception e)
{
Console.WriteLine("Can't connect: " + strHost + e);
Console.ReadLine();
}
sshCp.Connect(nPort);
try
{
while (true)
{
DirectoryInfo dirInfo = new DirectoryInfo(@"\\myruswclf\\SQL Folder\\Common Files\\RAE_Dialer");
foreach (FileInfo file in dirInfo.GetFiles())
{
sshCp.Put(file.DirectoryName + "\\" + file.Name, "\\opt\\avaya\\pds\\xfer\\public\\public\\");
Console.WriteLine("File " + file.Name + " moved to diler");
}
foreach (FileInfo file in dirInfo.GetFiles())
{
System.IO.File.Copy(file.DirectoryName + "\\" + file.Name, "\\\\myruswclf\\SQL Folder\\Common Files\\Archive_RAE_Dialer\\" + file.Name, true);
String mydate = DateTime.Now.ToString("yyyyMMdd_HHmm");
// Console.WriteLine(DateTime.Now.ToString("MM/dd/yyyy HH:mm"));
System.IO.File.Move("\\\\myruswclf\\SQL Folder\\Common Files\\Archive_RAE_Dialer\\" + file.Name, "\\\\myruswclf\\SQL Folder\\Common Files\\Archive_RAE_Dialer\\" + file.Name.Split('.')[0] + "_" + mydate + '.' + file.Name.Split('.')[1]);
Console.WriteLine("File " + file.Name.Split('.')[0] + "_" + mydate + '.' + file.Name.Split('.')[1] + " moved to archive");
}
Console.WriteLine("Waiting 300000ms ...");
Thread.Sleep(300000);
}
}
catch (Exception e)
{
Console.WriteLine("woops! Error " + strHost + e);
Console.ReadLine();
}
}
}
但是,当我尝试在另一个sftp服务器(本地)上执行此操作时,它的工作正常 哪里可以搞错?我做错了什么?请帮助我: - )