Цитата(Track @ 22.10.2013, 14:42 ) | Попросту говоря, владелец сервера таким образом защитился от заливки множества файлов. Программного решения тут быть не может - договаривайтесь с владельцем - остальные решения это уже хакин |
бред полный. Просто надо заливать файлы в рамках одного соединения последовательно. Цитата(t2000 @ 22.10.2013, 06:14 ) | не помогло :(( |
сдаётся мне вы нам врёте. Вот я написал (чуть поправив): Код | class Program { static void Main(string[] args) { FtpUload("ftp://***.ru/", "***", "***", @"c:\temp\2012-12-21_124923.png", "/var/www/temp/test/2012-12-21_124923.png"); FtpUload("ftp://***.ru/", "***", "***", @"c:\temp\2012-12-26_145930.png", "/var/www/temp/test/2012-12-26_145930.png"); FtpUload("ftp://***.ru/", "***", "***", @"c:\temp\2013-01-23_120403.png", "/var/www/temp/test/2013-01-23_120403.png"); }
public static void FtpUload(string ftpserver, string login, string password, string localPath, string filename) {
FtpWebRequest requestFTPUploader = (FtpWebRequest)WebRequest.Create(ftpserver + filename); requestFTPUploader.Credentials = new NetworkCredential(login, password); requestFTPUploader.Method = WebRequestMethods.Ftp.UploadFile; requestFTPUploader.KeepAlive = true; requestFTPUploader.ConnectionGroupName = "MyUploadGroup"; requestFTPUploader.ServicePoint.ConnectionLimit = 1;
FileInfo fileInfo = new FileInfo(localPath ); FileStream fileStream = fileInfo.OpenRead(); int bufferLength = 2048; byte[] buffer = new byte[bufferLength]; Stream uploadStream = requestFTPUploader.GetRequestStream(); int contentLength = fileStream.Read(buffer, 0, bufferLength); while (contentLength != 0) { uploadStream.Write(buffer, 0, contentLength); contentLength = fileStream.Read(buffer, 0, bufferLength); } uploadStream.Close(); fileStream.Close(); requestFTPUploader = null; }
}
|
+добавил логирование: Код | <?xml version="1.0" encoding="utf-8" ?> <configuration> <startup> <supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.5" /> </startup> <system.diagnostics> <sources> <source name="System.Net" tracemode="protocolonly" maxdatasize="1024"> <listeners> <add name="System.Net"/> </listeners> </source> </sources> <switches> <add name="System.Net" value="Information"/> </switches> <sharedListeners> <add name="System.Net" type="System.Diagnostics.TextWriterTraceListener" initializeData="network.log" /> </sharedListeners> <trace autoflush="true"/> </system.diagnostics> </configuration>
|
Итог в логах: Код | System.Net Information: 0 : [6516] FtpWebRequest#49911653::.ctor(ftp://***.ru//var/www/temp/test/2012-12-21_124923.png) System.Net Information: 0 : [6516] Current OS installation type is 'Client'. System.Net Information: 0 : [6516] RAS supported: True System.Net Information: 0 : [6516] FtpWebRequest#49911653::GetRequestStream(Method=STOR.) System.Net Information: 0 : [6516] FtpControlStream#35489797 - Created connection from ***:56702 to ***:21. System.Net Information: 0 : [6516] Associating FtpWebRequest#49911653 with FtpControlStream#35489797 System.Net Information: 0 : [6516] FtpControlStream#35489797 - Received response [220 ***.ru FTP server (Version 6.00LS) ready.] System.Net Information: 0 : [6516] FtpControlStream#35489797 - Sending command [USER ***] System.Net Information: 0 : [6516] FtpControlStream#35489797 - Received response [331 Password required for ***.] System.Net Information: 0 : [6516] FtpControlStream#35489797 - Sending command [PASS ********] System.Net Information: 0 : [6516] FtpControlStream#35489797 - Received response [230 User ***logged in.] System.Net Information: 0 : [6516] FtpControlStream#35489797 - Sending command [OPTS utf8 on] System.Net Information: 0 : [6516] FtpControlStream#35489797 - Received response [500 OPTS utf8 on: command not understood.] System.Net Information: 0 : [6516] FtpControlStream#35489797 - Sending command [PWD] System.Net Information: 0 : [6516] FtpControlStream#35489797 - Received response [257 "/var/www" is current directory.] System.Net Information: 0 : [6516] FtpControlStream#35489797 - Sending command [TYPE I] System.Net Information: 0 : [6516] FtpControlStream#35489797 - Received response [200 Type set to I.] System.Net Information: 0 : [6516] FtpControlStream#35489797 - Sending command [PASV] System.Net Information: 0 : [6516] FtpControlStream#35489797 - Received response [227 Entering Passive Mode (***)] System.Net Information: 0 : [6516] FtpControlStream#35489797 - Sending command [STOR /var/www/temp/test/2012-12-21_124923.png] System.Net Information: 0 : [6516] FtpControlStream#35489797 - Received response [150 Opening BINARY mode data connection for '/var/www/temp/test/2012-12-21_124923.png'.] System.Net Information: 0 : [6516] FtpControlStream#35489797 - Received response [226 Transfer complete.] System.Net Information: 0 : [6516] FtpWebRequest#49911653::(Releasing FTP connection#35489797.) System.Net Information: 0 : [6516] FtpWebRequest#45795543::.ctor(ftp://***.ru//var/www/temp/test/2012-12-26_145930.png) System.Net Information: 0 : [6516] FtpWebRequest#45795543::GetRequestStream(Method=STOR.) System.Net Information: 0 : [6516] Associating FtpWebRequest#45795543 with FtpControlStream#35489797 System.Net Information: 0 : [6516] FtpControlStream#35489797 - Sending command [PASV] System.Net Information: 0 : [6516] FtpControlStream#35489797 - Received response [227 Entering Passive Mode (***)] System.Net Information: 0 : [6516] FtpControlStream#35489797 - Sending command [STOR /var/www/temp/test/2012-12-26_145930.png] System.Net Information: 0 : [6516] FtpControlStream#35489797 - Received response [150 Opening BINARY mode data connection for '/var/www/temp/test/2012-12-26_145930.png'.] System.Net Information: 0 : [6516] FtpControlStream#35489797 - Received response [226 Transfer complete.] System.Net Information: 0 : [6516] FtpWebRequest#45795543::(Releasing FTP connection#35489797.) System.Net Information: 0 : [6516] FtpWebRequest#65677972::.ctor(ftp://***.ru//var/www/temp/test/2013-01-23_120403.png) System.Net Information: 0 : [6516] FtpWebRequest#65677972::GetRequestStream(Method=STOR.) System.Net Information: 0 : [6516] Associating FtpWebRequest#65677972 with FtpControlStream#35489797 System.Net Information: 0 : [6516] FtpControlStream#35489797 - Sending command [PASV] System.Net Information: 0 : [6516] FtpControlStream#35489797 - Received response [227 Entering Passive Mode (***)] System.Net Information: 0 : [6516] FtpControlStream#35489797 - Sending command [STOR /var/www/temp/test/2013-01-23_120403.png] System.Net Information: 0 : [6516] FtpControlStream#35489797 - Received response [150 Opening BINARY mode data connection for '/var/www/temp/test/2013-01-23_120403.png'.] System.Net Information: 0 : [6516] FtpControlStream#35489797 - Received response [226 Transfer complete.] System.Net Information: 0 : [6516] FtpWebRequest#65677972::(Releasing FTP connection#35489797.)
|
как видите USER один раз была....
--------------------
Что-то не поняли? -> Напейтесь до зеленых человечков... эта сверхцивилизация Вам поможет...
|