当前位置: 首页>>代码示例>>C#>>正文


C# DataConnection.Start方法代码示例

本文整理汇总了C#中DataConnection.Start方法的典型用法代码示例。如果您正苦于以下问题:C# DataConnection.Start方法的具体用法?C# DataConnection.Start怎么用?C# DataConnection.Start使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在DataConnection的用法示例。


在下文中一共展示了DataConnection.Start方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: APPE

		private void APPE(string argsText)
		{
            if(m_SessionRejected){
                WriteLine("500 Bad sequence of commands: Session rejected.");

                return;
            }
            if(!this.IsAuthenticated){
				WriteLine("530 Please authenticate firtst !");

				return;
			}
            if(string.IsNullOrEmpty(argsText)){
                WriteLine("501 Invalid file name.");
            }

			/*
				This command causes the server-DTP to accept the data
				transferred via the data connection and to store the data in
				a file at the server site.  If the file specified in the
				pathname exists at the server site, then the data shall be
				appended to that file; otherwise the file specified in the
				pathname shall be created at the server site.
			*/
			
			FTP_e_Appe eArgs = new FTP_e_Appe(argsText);
            OnAppe(eArgs);

            // Opearation failed.
            if(eArgs.Error != null){
                foreach(FTP_t_ReplyLine reply in eArgs.Error){
                    WriteLine(reply.ToString());
                }
            }
            // Opearation succeeded.
            else{
                if(eArgs.FileStream == null){
                    WriteLine("500 Internal server error: File stream not provided by server.");

                    return;
                }

                m_pDataConnection = new DataConnection(this,eArgs.FileStream,true);
                m_pDataConnection.Start();
            }
		}
开发者ID:dioptre,项目名称:nkd,代码行数:46,代码来源:FTP_Session.cs

示例2: NLST

		private void NLST(string argsText)
		{
            if(m_SessionRejected){
                WriteLine("500 Bad sequence of commands: Session rejected.");

                return;
            }			
			if(!this.IsAuthenticated){
				WriteLine("530 Please authenticate firtst !");

				return;
			}

            /*
				This command causes a directory listing to be sent from
				server to user site.  The pathname should specify a
				directory or other system-specific file group descriptor; a
				null argument implies the current directory.  The server
				will return a stream of names of files and no other
				information.  The data will be transferred in ASCII or
				EBCDIC type over the data connection as valid pathname
				strings separated by <CRLF> or <NL>.  (Again the user must
				ensure that the TYPE is correct.)  This command is intended
				to return information that can be used by a program to
				further process the files automatically.  For example, in
				the implementation of a "multiple get" function.
			*/

			FTP_e_GetDirListing eArgs = new FTP_e_GetDirListing(argsText);
            OnGetDirListing(eArgs);

            // Error getting directory listing.
            if(eArgs.Error != null){
                foreach(FTP_t_ReplyLine reply in eArgs.Error){
                    WriteLine(reply.ToString());
                }
            }
            // Listing succeeded.
            else{
                // Build directory listing.
                MemoryStreamEx retVal = new MemoryStreamEx(8000);
                foreach(FTP_ListItem item in eArgs.Items){
                    byte[] data = Encoding.UTF8.GetBytes(item.Name + "\r\n");
                    retVal.Write(data,0,data.Length);
                }
                retVal.Position = 0;                

                m_pDataConnection = new DataConnection(this,retVal,false);
                m_pDataConnection.Start();
            }
		}
开发者ID:dioptre,项目名称:nkd,代码行数:51,代码来源:FTP_Session.cs

示例3: STOR

		private void STOR(string argsText)
		{
            if(m_SessionRejected){
                WriteLine("500 Bad sequence of commands: Session rejected.");

                return;
            }
            if(!this.IsAuthenticated){
				WriteLine("530 Please authenticate firtst !");

				return;
			}
            if(string.IsNullOrEmpty(argsText)){
                WriteLine("501 Invalid file name.");
            }

			/*
				This command causes the server-DTP to transfer a copy of the
				file, specified in the pathname, to the server- or user-DTP
				at the other end of the data connection.  The status and
				contents of the file at the server site shall be unaffected.
			*/

            FTP_e_Stor eArgs = new FTP_e_Stor(argsText);
            OnStor(eArgs);

            // Opearation failed.
            if(eArgs.Error != null){
                foreach(FTP_t_ReplyLine reply in eArgs.Error){
                    WriteLine(reply.ToString());
                }
            }
            // Opearation succeeded.
            else{
                if(eArgs.FileStream == null){
                    WriteLine("500 Internal server error: File stream not provided by server.");

                    return;
                }

                m_pDataConnection = new DataConnection(this,eArgs.FileStream,true);
                m_pDataConnection.Start();
            }
		}
开发者ID:dioptre,项目名称:nkd,代码行数:44,代码来源:FTP_Session.cs

示例4: LIST

		private void LIST(string argsText)
		{
            if(m_SessionRejected){
                WriteLine("500 Bad sequence of commands: Session rejected.");

                return;
            }
            if(!this.IsAuthenticated){
				WriteLine("530 Please authenticate firtst !");

				return;
			}

			/*
				This command causes a list to be sent from the server to the
				passive DTP.  If the pathname specifies a directory or other
				group of files, the server should transfer a list of files
				in the specified directory.  If the pathname specifies a
				file then the server should send current information on the
				file.  A null argument implies the user's current working or
				default directory.  The data transfer is over the data
				connection in type ASCII or type EBCDIC.  (The user must
				ensure that the TYPE is appropriately ASCII or EBCDIC).
				Since the information on a file may vary widely from system
				to system, this information may be hard to use automatically
				in a program, but may be quite useful to a human user.
			*/

            FTP_e_GetDirListing eArgs = new FTP_e_GetDirListing(argsText);
            OnGetDirListing(eArgs);

            // Error getting directory listing.
            if(eArgs.Error != null){
                foreach(FTP_t_ReplyLine reply in eArgs.Error){
                    WriteLine(reply.ToString());
                }
            }
            // Listing succeeded.
            else{
                // Build directory listing.
                MemoryStreamEx retVal = new MemoryStreamEx(8000);
                foreach(FTP_ListItem item in eArgs.Items){
                    if(item.IsDir){
                        byte[] data = Encoding.UTF8.GetBytes(item.Modified.ToString("MM-dd-yy HH:mm") + " <DIR> " + item.Name + "\r\n");
					    retVal.Write(data,0,data.Length);
					}
					else{
                        byte[] data = Encoding.UTF8.GetBytes(item.Modified.ToString("MM-dd-yy HH:mm") + " " + item.Size.ToString() + " " + item.Name + "\r\n");
					    retVal.Write(data,0,data.Length);
					}
                }
                retVal.Position = 0;                

                m_pDataConnection = new DataConnection(this,retVal,false);
                m_pDataConnection.Start();
            }
		}
开发者ID:dioptre,项目名称:nkd,代码行数:57,代码来源:FTP_Session.cs


注:本文中的DataConnection.Start方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。