Beispiel #1
0
 public static Task <IEnumerable <FileInfo> > SynchronizeDirectoriesAsync(this SftpClient client,
                                                                          string sourcePath, string destinationPath, string searchPattern,
                                                                          TaskFactory <IEnumerable <FileInfo> > factory = null,
                                                                          TaskCreationOptions creationOptions           = default(TaskCreationOptions),
                                                                          TaskScheduler scheduler = null)
 {
     return((factory = factory ?? Task <IEnumerable <FileInfo> > .Factory).FromAsync(
                client.BeginSynchronizeDirectories(sourcePath, destinationPath, searchPattern, null, null),
                client.EndSynchronizeDirectories,
                creationOptions, scheduler ?? factory.Scheduler ?? TaskScheduler.Current));
 }
        public void Test_Sftp_BeginSynchronizeDirectories()
        {
            RemoveAllFiles();

            using (var sftp = new SftpClient(Resources.HOST, Resources.USERNAME, Resources.PASSWORD))
            {
                sftp.Connect();

                string uploadedFileName = Path.GetTempFileName();

                string sourceDir = Path.GetDirectoryName(uploadedFileName);
                string destDir = "/";
                string searchPattern = Path.GetFileName(uploadedFileName);

                var asyncResult = sftp.BeginSynchronizeDirectories(sourceDir,
                    destDir,
                    searchPattern,
                    null,
                    null
                );

                // Wait for the WaitHandle to become signaled.
                asyncResult.AsyncWaitHandle.WaitOne(1000);

                var upLoadedFiles = sftp.EndSynchronizeDirectories(asyncResult);

                Assert.IsTrue(upLoadedFiles.Count() > 0);

                foreach (var file in upLoadedFiles)
                {
                    Debug.WriteLine(file.FullName);
                }

                // Close the wait handle.
                asyncResult.AsyncWaitHandle.Close();

                sftp.Disconnect();
            }
        }
Beispiel #3
0
        public void Test_Sftp_BeginSynchronizeDirectories()
        {
            RemoveAllFiles();

            using (var sftp = new SftpClient(Resources.HOST, Resources.USERNAME, Resources.PASSWORD))
            {
                sftp.Connect();

                string uploadedFileName = Path.GetTempFileName();

                string sourceDir     = Path.GetDirectoryName(uploadedFileName);
                string destDir       = "/";
                string searchPattern = Path.GetFileName(uploadedFileName);

                var asyncResult = sftp.BeginSynchronizeDirectories(sourceDir,
                                                                   destDir,
                                                                   searchPattern,
                                                                   null,
                                                                   null
                                                                   );

                // Wait for the WaitHandle to become signaled.
                asyncResult.AsyncWaitHandle.WaitOne(1000);

                var upLoadedFiles = sftp.EndSynchronizeDirectories(asyncResult);

                Assert.IsTrue(upLoadedFiles.Count() > 0);

                foreach (var file in upLoadedFiles)
                {
                    Debug.WriteLine(file.FullName);
                }

                // Close the wait handle.
                asyncResult.AsyncWaitHandle.Close();

                sftp.Disconnect();
            }
        }
Beispiel #4
0
 public void BeginSynchronizeDirectoriesTest()
 {
     ConnectionInfo connectionInfo = null; // TODO: Initialize to an appropriate value
     SftpClient target = new SftpClient(connectionInfo); // TODO: Initialize to an appropriate value
     string sourcePath = string.Empty; // TODO: Initialize to an appropriate value
     string destinationPath = string.Empty; // TODO: Initialize to an appropriate value
     string searchPattern = string.Empty; // TODO: Initialize to an appropriate value
     AsyncCallback asyncCallback = null; // TODO: Initialize to an appropriate value
     object state = null; // TODO: Initialize to an appropriate value
     IAsyncResult expected = null; // TODO: Initialize to an appropriate value
     IAsyncResult actual;
     actual = target.BeginSynchronizeDirectories(sourcePath, destinationPath, searchPattern, asyncCallback, state);
     Assert.AreEqual(expected, actual);
     Assert.Inconclusive("Verify the correctness of this test method.");
 }