In general, C # provides a very simple FTP method. The encapsulated ftpwebrequest and ftpwebresponse make FTP module development very simple. However, after encapsulation, many custom customization problems may occur, which are not detailed here. The following are some of the problems encountered during this period:
Try{This. Ftpuri =NewUri (ftppath );This. Webrequest = (ftpwebrequest) webrequest. Create (ftpuri );If((Bool) Radiobutton_binary.ischecked) {webrequest. usebinary =True;}Else{Webrequest. usebinary =False;} Webrequest. Credentials =NewNetworkcredential (ftpconfig. ftpusername, ftpconfig. ftppasswd );}
AboveCodeContent initialized for the FTP connection. Webrequest. method = webrequestmethods. FTP. uploadfile; method indicates the FTP operation to be performed. However, the above Code operation is required for each operation during FTP encapsulation,
Ftpwebrequest does not provide a session persistence mechanism (or is it provided, I have not found it? Can't automatically keep the session after the connection times out like some FTP tools. networkcredential is an unpleasant operation every time.
During PS file upload, you can use delegate to keep the UI active. Multi-threading is preferred for uploading multiple files.