c# - FTP - Uploading a file in a diffrent name -
i have form has radiobuttons, each of them giving file name in string, , want have string name file user uploads.
it'll great if explain me how rename, because got code upload or me modify function, have add 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 } catch (system.argumentexception) { // handled } 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: files rtf (richtextbox).
thanks!
just upload different url then. replace new fileinfo(filename).name in code name want. also, think not using string manipulation better. , stor command default.
client.uploadfileasync(new uri(new uri("ftp://ftpaddress.com"), newname)), filename);
Comments
Post a Comment