ftpwebrequest

Recursive upload to FTP server in C#

北战南征 提交于 2020-04-05 05:28:27
问题 I would need to upload a folder (which contains sub folders and files) from one server to another from C# code. I have done few research and found that we can achieve this using FTP. But with that I am able to move only files and not the entire folder. Any help here is appreciated. 回答1: The FtpWebRequest (nor any other FTP client in .NET framework) indeed does not have any explicit support for recursive file operations (including uploads). You have to implement the recursion yourself: List

Download new and modified files from an FTP server

风流意气都作罢 提交于 2020-01-23 11:51:55
问题 I'm trying to get a list of the files on an FTP server, then one by one check if that file exists on the local system and if it does compare the dates modified and if the ftp file is newer download it. private void btnGo_Click(object sender, EventArgs e) { string[] files = GetFileList(); foreach (string file in files) { if (file.Length >= 5) { string uri = "ftp://" + ftpServerIP + "/" + remoteDirectory + "/" + file; Uri serverUri = new Uri(uri); CheckFile(file); } } this.Close(); } public

Download new and modified files from an FTP server

ε祈祈猫儿з 提交于 2020-01-23 11:51:21
问题 I'm trying to get a list of the files on an FTP server, then one by one check if that file exists on the local system and if it does compare the dates modified and if the ftp file is newer download it. private void btnGo_Click(object sender, EventArgs e) { string[] files = GetFileList(); foreach (string file in files) { if (file.Length >= 5) { string uri = "ftp://" + ftpServerIP + "/" + remoteDirectory + "/" + file; Uri serverUri = new Uri(uri); CheckFile(file); } } this.Close(); } public

Upload a file with FTP in C# : The format of the URI could not be determined

不想你离开。 提交于 2020-01-21 20:31:46
问题 I'm trying to upload a file with ftp in C#. for the moment, i try to do it locally: static void Main(string[] args) { UploadFileToFtp("C:\\Utilisateurs\\arnaud\\Bureau\\yhyhyyh.rtf","root","root"); } public static void UploadFileToFtp(string filePath, string username, string password) { var fileName = Path.GetFileName(filePath); var request = (FtpWebRequest)WebRequest.Create("127.0.0.1/" + fileName);<---ERROR request.Method = WebRequestMethods.Ftp.UploadFile; request.Credentials = new

Upload a file with FTP in C# : The format of the URI could not be determined

不羁的心 提交于 2020-01-21 20:31:09
问题 I'm trying to upload a file with ftp in C#. for the moment, i try to do it locally: static void Main(string[] args) { UploadFileToFtp("C:\\Utilisateurs\\arnaud\\Bureau\\yhyhyyh.rtf","root","root"); } public static void UploadFileToFtp(string filePath, string username, string password) { var fileName = Path.GetFileName(filePath); var request = (FtpWebRequest)WebRequest.Create("127.0.0.1/" + fileName);<---ERROR request.Method = WebRequestMethods.Ftp.UploadFile; request.Credentials = new

System.Net.FtpWebRequest GetDateTimestamp call dies

℡╲_俬逩灬. 提交于 2020-01-17 03:26:06
问题 Following test works... public void test1() { string server="ftp://myserver.com/dev"; string userName="myusername"; string password="mypassword"; FtpWebRequest req = (FtpWebRequest)WebRequest.Create( server ); req.Credentials = new NetworkCredential( userName, password ); req.Method = WebRequestMethods.Ftp.ListDirectoryDetails; req.Timeout = 30000; req.UseBinary = false; req.EnableSsl = false; req.UsePassive = false; req.KeepAlive = true; using( FtpWebResponse resp = (FtpWebResponse)req

The remote server returned an error: 227 Entering Passive Mode (500 oops vs_utility_recv_peek: no data)

情到浓时终转凉″ 提交于 2020-01-10 19:33:26
问题 I am having a problem connecting a Windows service to an FTP site. I inherited a Windows service from another developer. The service connects to a 3rd party server, downloads a csv file and then processes it. For some reason, the service stopped working (well over a year ago, before I was given the project). So I went back to basics, created a console app and tried the connection/ file download function only in that app. I have tried many different methods to connect to the FTP, but all of

Unable to FTP to MainFrame Location

扶醉桌前 提交于 2020-01-07 09:02:15
问题 I tried Retrieving a file from a mainframe location .. using FtpWebRequest. Every thing is working fine with Other general Servers and Getting issue only for mainframe here is the message 550 Command RETR fails: /'XXX.XXX.XXX.XX.TXT' does not exist.\r\n I believe the URI which I am creating its because of that , you can see a "/" in that message . here is my URI = ftp ://data.data.com//'XXX.XXX.XXX.XX.TXT' 回答1: There has been a change made to the FtpWebRequest class from .Net 2.0/3.5 to .Net

How to create a fake FtpWebResponse

南笙酒味 提交于 2020-01-05 08:34:46
问题 I am trying to fake an FtpWebRequest.GetResponse() for an integration test, but without using a server. What I have been trying to do is the simple return a fake FtpWebResponse but, you are not allowed to access the constructor for the FtpWebResponse because it is internal. Here is my code: Production code: using (FtpWebResponse response = (FtpWebResponse) ftpWebRequest.GetResponse()) { ftpResponse = new FtpResponse(response.StatusDescription, false); } Test fake I am trying to use to return

.Net FtpWebRequest fails sometimes

天大地大妈咪最大 提交于 2020-01-03 08:52:49
问题 I try to list file details using FtpWebRequest but very frequently it fails with a WebException and shows error 530 User not logged in. How is this possible, that it works some of the time using the same credentials? Excerpt from code: reqFTP = (FtpWebRequest)FtpWebRequest.Create(new Uri(ftpuri)); reqFTP.UseBinary = true; reqFTP.Credentials = new NetworkCredential(userName, password); string[] downloadFiles = new string[0]; reqFTP.Method = WebRequestMethods.Ftp.ListDirectoryDetails;