| 
			
			 | 
		#1 | 
| 
			
			 Участник 
		
			
	 | 
	
	
	
		
		
			
			
			FTP в АХ5
			 
			
			Как можно из АХ5 создать файл на FTP Server ? В Ах4 есть класс WinInnet а здесь его нету.  
		
		
		
		
		
		
		
	Меня интерисует создать техтовый файл с двнными на FTP Server а вот как ?  | 
| 
	
 | 
| 
			
			 | 
		#2 | 
| 
			
			 Участник 
		
			
	 | 
	
	
	
		
		
		
		 
			
			я бы написал пользуясь интеграцией с .NET, например портировал бы отсюда 
		
		
		
		
		
		
		
		
			http://www.vcskicks.com/csharp_ftp_upload.html Последний раз редактировалось belugin; 07.05.2009 в 15:52.  | 
| 
	
 | 
| 
			
			 | 
		#3 | 
| 
			
			 Участник 
		
			
	 | 
	
	
	
		
		
		
		 
			
			Нужно средствами Ах.
		 
		
		
		
		
		
		
		
	 | 
| 
	
 | 
| 
			
			 | 
		#4 | 
| 
			
			 Участник 
		
			
	 | 
	
	
	
		
		
		
		 
			
			Средствами ax не получится - все равно будет обращение к чему-то вешнему, DLL COM или .NET. 
		
		
		
		
		
		
		
	.NET проще тем, что там больше возможостей и он интергрирован в язык. Вам не надо создавать никаких сборок - просто надо перевести код по ссылке на X++ типа: X++: static void Job1(Args _args) { System.Net.WebRequest webRequest = System.Net.WebRequest::Create('ftp://ftp.microsoft.com/Softlib/README.TXT'); System.Net.FtpWebRequest request; System.Net.NetworkCredential credential = new System.Net.NetworkCredential("anonymous","janeDoe@contoso.com"); System.Net.FtpWebResponse response; Object o; ; o = webRequest; request = o; request.set_Credentials(credential); response = request.GetResponse(); info(response.get_StatusDescription()); info('ok'); }  | 
| 
	
 | 
| 
			
			 | 
		#5 | 
| 
			
			 Участник 
		
			
	 | 
	
	
	
		
		
		
		 
			
			А как преоброзовать этот код: 
		
		
		
		
		
		
		
	X++:             request.Method = WebRequestMethods.Ftp.UploadFile;    - #
            request.set_Method(?);                                                     AX5
 
            //Load the file
            FileStream stream = File.OpenRead(filePath);
            byte[] buffer = new byte[stream.Length];
            stream.Read(buffer, 0, buffer.Length);
            stream.Close();
            //Upload file
            Stream reqStream = request.GetRequestStream();
            reqStream.Write(buffer, 0, buffer.Length);
            reqStream.Close(); | 
| 
	
 | 
| 
			
			 | 
		#6 | 
| 
			
			 Участник 
		
			
	 | 
	
	
	
		
		
		
		 
			
			судя по описанию, это - строковая rконстанта и ее значение можно посмотреть в Visual STudio
		 
		
		
		
		
		
		
		
	 | 
| 
	
 | 
| 
			
			 | 
		#7 | 
| 
			
			 очами вижу 
		
			
	 | 
	
	
	
		
		
		
		 Цитата: 
	
		
			Сообщение от belugin
			 
 
			судя по описанию, это - строковая rконстанта и ее значение можно посмотреть в Visual STudio 
		
	Студия для того, чтобы посмотреть исходники библиотеки, не обязательна. Есть прекрасная утилита Reflector. С ее помощью можно увидеть такую картину для типа System.Net.WebRequestMethods.Ftp: X++: /// <summary>Represents the types of FTP protocol methods that can be used with an FTP request. This class cannot be inherited.</summary> public static class Ftp { /// <summary>Represents the FTP APPE protocol method that is used to append a file to an existing file on an FTP server.</summary> public const string AppendFile = "APPE"; /// <summary>Represents the FTP DELE protocol method that is used to delete a file on an FTP server.</summary> public const string DeleteFile = "DELE"; /// <summary>Represents the FTP RETR protocol method that is used to download a file from an FTP server.</summary> public const string DownloadFile = "RETR"; public const string GetDateTimestamp = "MDTM"; /// <summary>Represents the FTP SIZE protocol method that is used to retrieve the size of a file on an FTP server.</summary> public const string GetFileSize = "SIZE"; /// <summary>Represents the FTP NLIST protocol method that gets a short listing of the files on an FTP server.</summary> public const string ListDirectory = "NLST"; /// <summary>Represents the FTP LIST protocol method that gets a detailed listing of the files on an FTP server.</summary> public const string ListDirectoryDetails = "LIST"; /// <summary>Represents the FTP MKD protocol method creates a directory on an FTP server.</summary> public const string MakeDirectory = "MKD"; /// <summary>Represents the FTP PWD protocol method that prints the name of the current working directory.</summary> public const string PrintWorkingDirectory = "PWD"; /// <summary>Represents the FTP RMD protocol method that removes a directory.</summary> public const string RemoveDirectory = "RMD"; /// <summary>Represents the FTP RENAME protocol method that renames a directory.</summary> public const string Rename = "RENAME"; /// <summary>Represents the FTP STOR protocol method that uploads a file to an FTP server.</summary> public const string UploadFile = "STOR"; /// <summary>Represents the FTP STOU protocol that uploads a file with a unique name to an FTP server.</summary> public const string UploadFileWithUniqueName = "STOU"; }  | 
| 
	
 | 
| 
			
			 | 
		#8 | 
| 
			
			 Участник 
		
			
	 | 
	
	
	
		
		
		
		 
			
			Спасибо все получилось. Вот скипт для других: 
		
		
		
		
		
		
		
	X++: static void ag_FTPex1(Args _args) { TextBuffer tb; System.Net.WebRequest ftp = System.Net.WebRequest::Create(ftpAddress); System.Net.FtpWebRequest request; System.Net.NetworkCredential credential = new System.Net.NetworkCredential(user, password); System.Net.FtpWebResponse response; Object o; System.IO.Stream stream; System.Byte b; System.Text.Encoding e; ; try { o = ftp; request = o; request.set_Credentials(credential); ftp.set_Method("APPE"); e = System.Text.Encoding::get_Default(); stream = ftp.GetRequestStream(); stream.Write(e.GetBytes("12\n"), 0, 3 ); } catch { info ('FTP connection failed'); } if (stream) { stream.Close(); } if (ftp) { ftp.Abort(); } pause; }  | 
| 
	
 | 
|
| За это сообщение автора поблагодарили: belugin (3), alex55 (1). | |
| Теги | 
| ftp, законченный пример, полезное, ax2009 | 
| 
	
	 | 
	
			 
			Похожие темы
		 | 
	||||
| Тема | Ответов | |||
| работа по FTP | 9 | |||
| msdynamicsax: FTP-client within Ax | 0 | |||
| FTP и SSL | 1 | |||
| FTP FtpFindFirstFileA реализация? | 7 | |||
| Опции темы | Поиск в этой теме | 
| Опции просмотра | |
		
  |