public void TestUserReportedError2() { // clean up anything that may have been left over from previous tests FtpsClient ftp1 = new FtpsClient(FTP_HOST, FTP_STD_PORT, FtpsSecurityProtocol.None); ftp1.NetworkProtocol = NETWORK_PROTOCOL; ftp1.Open(FTP_USER, FTP_PASS); try { ftp1.ChangeDirectory("test dir"); } catch { } try { ftp1.DeleteFile("testfile.txt"); } catch { } try { ftp1.ChangeDirectory("\\"); } catch { } try { ftp1.DeleteDirectory("test dir"); } catch { } FtpsClient ftp = new FtpsClient(FTP_HOST, FTP_STD_PORT, FtpsSecurityProtocol.Tls12Explicit); ftp.NetworkProtocol = NETWORK_PROTOCOL; ftp.AlwaysAcceptServerCertificate = true; ftp.Open(FTP_USER, FTP_PASS); ftp.MakeDirectory("test dir"); ftp.ChangeDirectory("test dir"); ftp.PutFile(GetMemoryStreamRandom(100), "testfile.txt", FileAction.Create); FtpsItemCollection col = ftp.GetDirList(); ftp.Close(); Assert.IsTrue(col.Count == 1); }
public void TestChangeDirectory(string host, int port, FtpsSecurityProtocol protocol, string user, string pwd) { using (FtpsClient c = new FtpsClient(host, port, protocol)) { c.NetworkProtocol = NETWORK_PROTOCOL; c.AlwaysAcceptServerCertificate = true; c.Open(user, pwd); Assert.IsTrue(c.IsConnected); string dir1 = Guid.NewGuid().ToString(); string dir2 = Guid.NewGuid().ToString(); string dir3 = Guid.NewGuid().ToString(); string dir4 = Guid.NewGuid().ToString(); // create the directories and change into them c.MakeDirectory(dir1); c.ChangeDirectory(dir1); c.MakeDirectory(dir2); c.ChangeDirectory(dir2); c.MakeDirectory(dir3); c.ChangeDirectory(dir3); c.MakeDirectory(dir4); c.ChangeDirectoryUp(); c.ChangeDirectoryUp(); c.ChangeDirectoryUp(); c.ChangeDirectoryUp(); // try changing directory using a full path which does // not work for all FTP servers c.ChangeDirectory(String.Format("{0}/{1}/{2}/{3}", dir1, dir2, dir3, dir4)); c.ChangeDirectory("//"); // try changing directory using multipath command which should work // for all FTP servers c.ChangeDirectoryMultiPath(String.Format("{0}/{1}/{2}/{3}", dir1, dir2, dir3, dir4)); c.ChangeDirectoryUp(); // delete the temporary directories c.DeleteDirectory(dir4); c.ChangeDirectoryUp(); c.DeleteDirectory(dir3); c.ChangeDirectoryUp(); c.DeleteDirectory(dir2); c.ChangeDirectoryUp(); c.DeleteDirectory(dir1); } }
public void TestUserReportedError2() { FtpsClient ftp = new FtpsClient(FTP_HOST, FTP_STD_PORT, FtpsSecurityProtocol.Tls1Explicit); ftp.NetworkProtocol = NETWORK_PROTOCOL; ftp.AlwaysAcceptServerCertificate = true; ftp.Open(FTP_USER, FTP_PASS); ftp.MakeDirectory("test dir"); ftp.ChangeDirectory("test dir"); ftp.PutFile(GetMemoryStreamRandom(100), "testfile.txt", FileAction.Create); FtpsItemCollection col = ftp.GetDirList(); ftp.DeleteFile("testfile.txt"); ftp.ChangeDirectory("\\"); ftp.DeleteDirectory("test dir"); ftp.Close(); Assert.IsTrue(col.Count == 1); }
public void UploadPackage(string packagePath, string packageVersion) { _packageFtpsClient = GetNewFtpsClient(); _packageFtpsClient.TransferProgress += TransferProgressChangedEventHandler; _packageFtpsClient.PutFileAsyncCompleted += UploadPackageFinished; _packageFtpsClient.Open(Username, Password.ConvertToInsecureString()); _packageFtpsClient.ChangeDirectoryMultiPath(Directory); _packageFtpsClient.MakeDirectory(packageVersion); _packageFtpsClient.ChangeDirectory(packageVersion); _packageFtpsClient.PutFileAsync(packagePath, FileAction.Create); _uploadPackageResetEvent.WaitOne(); _packageFtpsClient.Close(); _uploadPackageResetEvent.Reset(); }