コード例 #1
0
        public void CreateDirectoryTest()
        {
            EstablishConnection();

            String directoryName = "temporary_test_directory";

            // Create directory
            DFtpAction action = new CreateDirectoryRemoteAction(client, directoryName);
            DFtpResult result = action.Run();

            // Check for error
            Assert.True(result.Type == DFtpResultType.Ok);

            // Get listing and check that directory exists
            FtpListItem[] files = client.GetListing("/");
            bool          found = false;

            foreach (FtpListItem item in files)
            {
                if (item.Name == directoryName)
                {
                    found = true;
                }
            }
            Assert.True(found);

            client.DeleteDirectory("/" + directoryName);

            return;
        }
コード例 #2
0
        internal DFtpFile CreateAndPutDirectoryOnServer(FtpClient ftpClient, String remoteDirectory = testDirectory)
        {
            String dirpath = Path.GetDirectoryName(remoteDirectory);
            //String localDirectory = Path.GetDirectoryName(filepath);
            DFtpFile localSelection = new DFtpFile(dirpath, FtpFileSystemObjectType.Directory);

            DFtpAction action = new CreateDirectoryRemoteAction(client, dirpath);

            DFtpResult result = action.Run();

            return(localSelection);
        }
コード例 #3
0
        internal DFtpFile CreateAndPutFileOnServer(FtpClient ftpClient, String newFileName)
        {
            String     filepath       = Path.GetTempFileName();
            String     localDirectory = Path.GetDirectoryName(filepath);
            DFtpAction action         = new CreateDirectoryRemoteAction(ftpClient, test_Dir);
            DFtpResult test           = action.Run();
            DFtpFile   localSelection = new DFtpFile(filepath, FtpFileSystemObjectType.File);
            DFtpAction fileaction     = new PutFileAction(client, localDirectory, localSelection, test_Dir);

            DFtpResult result = fileaction.Run();

            return(localSelection);
        }
コード例 #4
0
        public DFtpResult Go()
        {
            String name = IOHelper.AskString("Enter new directory name.");

            // Create the action, Initialize it with the info we've collected
            DFtpAction action = new CreateDirectoryRemoteAction(Client.ftpClient, Client.remoteDirectory + "/" + name);

            // Carry out the action and get the result
            DFtpResult result = action.Run();

            // Give some feedback if successful
            if (result.Type == DFtpResultType.Ok)
            {
                IOHelper.Message("The directory '" + name + "' was created successfully.");
            }
            // Return the result after running.

            return(result);
        }