ftpwebrequest

How to improve the Performance of FtpWebRequest?

删除回忆录丶 提交于 2019-11-26 08:03:33
问题 I have an application written in .NET 3.5 that uses FTP to upload/download files from a server. The app works fine but there are performance issues: It takes a lot of time to make connection to the FTP server. The FTP server is on a different network and has Windows 2003 Server (IIS FTP). When multiple files are queued for upload, the change from one file to another creates a new connection using FTPWebRequest and it takes a lot of time (around 8-10 seconds). Is is possible to re-use the

“Requested URI is invalid” during upload with FTPWebRequest

旧巷老猫 提交于 2019-11-26 06:46:54
问题 I trying upload file to a directory on a FTP server. I used this method with FtpWebRequest . I would like to upload one file to a home directory for this user, but I always get the following error message: The requested URI is invalid for this FTP command. What can be problem? I tried use passive mode off, but it still the same. static void FtpUpload() { // Get the object used to communicate with the server. FtpWebRequest request = (FtpWebRequest)WebRequest.Create(\"ftp://12.22.44.45\");

Retrieving creation date of file (FTP)

安稳与你 提交于 2019-11-26 04:53:50
问题 I\'m using the System.Net.FtpWebRequest class and my code is as follows: FtpWebRequest request = (FtpWebRequest)WebRequest.Create(\"ftp://example.com/folder\"); request.Method = WebRequestMethods.Ftp.ListDirectory; request.Credentials = new NetworkCredential(\"username\", \"password\"); FtpWebResponse response = (FtpWebResponse)request.GetResponse(); Stream responseStream = response.GetResponseStream(); StreamReader reader = new StreamReader(responseStream); string names = reader.ReadToEnd();

How can we show progress bar for upload with FtpWebRequest

|▌冷眼眸甩不掉的悲伤 提交于 2019-11-26 04:46:04
问题 I am uploading files to ftp using FtpWebRequest . I need to show the status that how much is done. So far my code is: public void Upload(string filename, string url) { FileInfo fileInf = new FileInfo(filename); string uri = \"ftp://\" + url + \"/\" + fileInf.Name; FtpWebRequest reqFTP; //string uri = \"ftp://\" + Host + \"/public_html/testing/blogtest/\" + fileInf.Name; // Create FtpWebRequest object from the Uri provided reqFTP = (FtpWebRequest)FtpWebRequest.Create(new Uri(uri)); // Provide

How to check if file exists on FTP before FtpWebRequest

烂漫一生 提交于 2019-11-26 03:56:27
问题 I need to use FtpWebRequest to put a file in a FTP directory. Before the upload, I would first like to know if this file exists. What method or property should I use to check if this file exists? 回答1: var request = (FtpWebRequest)WebRequest.Create ("ftp://ftp.domain.com/doesntexist.txt"); request.Credentials = new NetworkCredential("user", "pass"); request.Method = WebRequestMethods.Ftp.GetFileSize; try { FtpWebResponse response = (FtpWebResponse)request.GetResponse(); } catch (WebException

Upload and download a binary file to/from FTP server in C#/.NET

无人久伴 提交于 2019-11-26 03:28:44
问题 I am using .NET 4 C#. I am trying to upload and then download a ZIP file to (my) server. For uploading I have using (WebClient client = new WebClient()) { FtpWebRequest request = (FtpWebRequest)WebRequest.Create(MyUrl); request.Method = WebRequestMethods.Ftp.UploadFile; request.EnableSsl = false; request.Credentials = new NetworkCredential(MyLogin, MyPassword); byte[] fileContents = null; using (StreamReader sourceStream = new StreamReader(LocalFilePath)) { fileContents = Encoding.UTF8

C# class to parse WebRequestMethods.Ftp.ListDirectoryDetails FTP response

柔情痞子 提交于 2019-11-26 03:27:32
问题 I\'m creating a service to monitor FTP locations for new updates and require the ability to parse the response returned from a FtpWebRequest response using the WebRequestMethods.Ftp.ListDirectoryDetails method. It would be fairly easy if all responses followed the same format, but different FTP server software provide different response formats. For example one might return: 08-10-11 12:02PM <DIR> Version2 06-25-09 02:41PM 144700153 image34.gif 06-25-09 02:51PM 144700153 updates.txt 11-04-10

Parsing FtpWebRequest ListDirectoryDetails line

梦想的初衷 提交于 2019-11-26 02:24:21
问题 I need some help with parsing the response from ListDirectoryDetails in C#. I only need the following fields. File Name/Directory Name Date Created and the File Size. Here\'s what some of the lines look like when I run ListDirectoryDetails : d--x--x--x 2 ftp ftp 4096 Mar 07 2002 bin -rw-r--r-- 1 ftp ftp 659450 Jun 15 05:07 TEST.TXT -rw-r--r-- 1 ftp ftp 101786380 Sep 08 2008 TEST03-05.TXT drwxrwxr-x 2 ftp ftp 4096 May 06 12:24 dropoff Thanks in advance. 回答1: Not sure if you still need this,

C# Download all files and subdirectories through FTP

旧街凉风 提交于 2019-11-26 00:38:27
问题 General Info I\'m still in the process of learning C#. To help myself out, I\'m trying to create a program that will automatically synchronise all of my local projects with a folder on my FTP server. This so that whether I\'m at school or at home, I always have the same projects available to me. I know there are programs like Dropbox that already do this for me, but I figured creating something like that myself will teach me a lot along the way. The problem My first step towards my goal was

Output log using FtpWebRequest

你离开我真会死。 提交于 2019-11-25 21:56:19
问题 I wonder if it\'s possible to have output log for my FTP client using FtpWebRequest . Something like this: [R] USER xxx [R] 331 Please specify the password. [R] PASS (hidden) [R] 230 Login successful. [R] SYST [R] 215 UNIX Type: L8 [R] FEAT [R] 211-Features: [R] EPRT [R] EPSV [R] MDTM [R] PASV [R] REST STREAM [R] SIZE [R] TVFS [R] 211 End [R] PWD [R] 257 \"/\" [R] CWD / [R] 250 Directory successfully changed. [R] PWD [R] 257 \"/\" [R] TYPE A [R] 200 Switching to ASCII mode. [R] PASV [R] 227