Example #1
0
		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();
            }
		}
Example #2
0
 /// <summary>
 /// Raises <b>GetDirListing</b> event.
 /// </summary>
 /// <param name="e">Event arguments.</param>
 private void OnGetDirListing(FTP_e_GetDirListing e)
 {
     if(this.GetDirListing != null){
         this.GetDirListing(this,e);
     }
 }
Example #3
0
		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();
            }
		}