FTP directory selection

  • Thread starter Thread starter SBMcA
  • Start date Start date
S

SBMcA

Guest
Hello,

May I first apologize for opening another thread so soon after my last one. Ive searched the internet for the last two days and cannot find a solution.

I currently have a feature which allows me to upload an image to an ftp directory which is listed inside a textbox - I would like to upgrade this so I could get the list of folders which are stored in the ftp server and have them displayed inside a combo box or something similar.

I would then like to be able to simply choose which directory I want to upload to by clicking on the relevant directory name listed in the combo box. By doing this it will change my ftp URL path and the chosen image will upload to the selected directory.

Is this possible inside windows forms using visual studio?

Below is my current code:

private void ConnectAndUpload()
{
try
{
string username = label61.Text;
string password = label62.Text;
string URLPath = maskedTextBox1.Text;
string FilePath = textBox_image_path.Text;




using (System.Net.WebClient client = new System.Net.WebClient())
{
client.Credentials = new System.Net.NetworkCredential(username, password);
client.UploadFile(URLPath + "/" + new FileInfo(FilePath).Name, "STOR", FilePath);
MessageBox.Show("Image uploaded successfully");
}

}

catch (Exception)
{
MessageBox.Show("FTP Upload failed, please check all your details are correct",
"FTP Upload Failed",
MessageBoxButtons.OK,
MessageBoxIcon.Error);
}


}


Again, thanks so much for any help

Continue reading...
 
Back
Top