I have a form which has radiobuttons, each of them is giving a file name in a string, and what I want to do is to have that string as a name for any file that a user uploads.
It'll be great if you could explain to me how to rename, because I already got it the code to upload or just help me modify this function, I would probably have to add to the parameters "string type" tho:
public void uploadFTP(string filename, string type, string password, ProgressBar progressbar)
{
WebClient client = new WebClient();
client.Credentials = new System.Net.NetworkCredential("username", password);
try
{
client.UploadFileAsync(new Uri(@"ftp://ftpaddress.com" + "/" + new FileInfo(filename).Name), "STOR", filename);
}
catch(System.InvalidCastException)
{
// Handled it
}
catch (System.ArgumentException)
{
// Handled it
}
client.UploadProgressChanged += (s, e) =>
{
progressbar.Value = e.ProgressPercentage;
};
client.UploadFileCompleted += (s, e) =>
{
MessageBox.Show("Upload complete", "Message", MessageBoxButtons.OK, MessageBoxIcon.Information, MessageBoxDefaultButton.Button1);
};
}
If it's important: The files are RTF (RichTextBox).
Thanks!