jeffwest21
IS-IT--Management
I am trying to set up a system to pull data from more than 1 sftp site at timed intervals during the day.
I have found a piece of work that someone else did that does it from one, but I need to as I say from a second as well.
The code I have in the app config is this.
I then have this is a download manager
what I want to do is add the Directory1 then Directory2 into the rootPath in order to do this, but nothing I do seems to work, it just fails, however, if I add the entire path into the rootPath then it works, so I know the connection is right, just the added bit is wrong.
'Clever boy...'
I have found a piece of work that someone else did that does it from one, but I need to as I say from a second as well.
The code I have in the app config is this.
Code:
<appSettings>
<add key ="Extra1" value ="folder1/"/>
<add key ="Extra2" value ="folder1/folder2/"/>
</appSettings>
<sftp remoteHost="sftp.blah.blah.blah" port="22" username="user" password="password" rootPath ="/folder/folder/folder/folder/ "> </sftp>
I then have this is a download manager
Code:
DirectoryInfo localRootInfo = new DirectoryInfo(ConfigurationManager.AppSettings["ToProcessFolder"].ToString());
DirectoryInfo localSubRootInfo = localRootInfo.CreateSubdirectory(string.Format("{0:yyyyMMdd-HHmmss}", DateTime.Now));
string Directory1 = ConfigurationManager.AppSettings["Extra1"];
string Directory2 = ConfigurationManager.AppSettings["Extra2"];
using (SftpManager sftp = new SftpManager())
{
// Loop through all of the folders and download if file available - NB These contain the WAV Files
foreach (var directory in sftp.GetAllDirectories(sftp.RootDirectory))
{
//string remoteWorkingFolder = string.Format("{0}{1}", sftp.RootDirectory, directory);
string subfolderName = Path.Combine(localSubRootInfo.FullName, directory.Name);
DirectoryInfo serviceLocalSubFolderInfo = new DirectoryInfo(subfolderName);
foreach (var file in sftp.GetAllFiles(directory.FullName))
{
if (!serviceLocalSubFolderInfo.Exists) serviceLocalSubFolderInfo.Create();
string localFilename = Path.Combine(serviceLocalSubFolderInfo.FullName, file.Name);
what I want to do is add the Directory1 then Directory2 into the rootPath in order to do this, but nothing I do seems to work, it just fails, however, if I add the entire path into the rootPath then it works, so I know the connection is right, just the added bit is wrong.
'Clever boy...'