Xceed .NET Libraries Documentation
Xceed.Ftp Assembly / Xceed.Ftp Namespace / FtpConnection Class / ParsingListingLine Event
Example


In This Topic
    ParsingListingLine Event (FtpConnection)
    In This Topic
    Raised when a listing line is received from the FTP server.
    Syntax
    'Declaration
     
    Public Event ParsingListingLine As ParsingListingLineEventHandler
    'Usage
     
    Dim instance As FtpConnection
    Dim handler As ParsingListingLineEventHandler
     
    AddHandler instance.ParsingListingLine, handler
    public event ParsingListingLineEventHandler ParsingListingLine
    Event Data

    The event handler receives an argument of type ParsingListingLineEventArgs containing data related to this event. The following ParsingListingLineEventArgs properties provide information specific to this event.

    PropertyDescription
    Gets an FtpItemInfo object representing the listing information of an FTP item.  
    Gets the listing line which was returned by the FTP server and used to create the Item.  
    Gets or sets a boolean value indicating if the listing line returned by the FTP server was valid.  
    Remarks

    If e.Valid is true when the event is raised, at least one parser succeeded in parsing the listing line and e.Item has been filled with the parsed information. To filter (remove) an item from the listing set e.Valid to false. The content of e.Item can also be modified if you want to change the item's information.

    If e.Valid is false when the event is raised, none of the parsers succeeded in parsing the listing line. In this case custom parsing can be provided by filling e.Item and setting e.Valid to true.

    Calls to the Xceed.FileSystem.AbstractFolder.GetFiles, Xceed.FileSystem.AbstractFolder.GetFolders and Xceed.FileSystem.AbstractFolder.GetItems methods will raise this event.

    Example
    The following example demonstrates how to use the ParsingListingLine event to remove the "." and ".." FTP items from the listing.
    Using connection As New FtpConnection("ftp.xceed.com")
      AddHandler connection.ParsingListingLine, AddressOf parsing_line
      Dim destination As New FtpFolder(connection, "ftp_test")
      destination.GetItems(True)
    End Using
    
    Private Sub parsing_line(ByVal sender As Object, ByVal e As ParsingListingLineEventArgs)
      If (e.Item.Name = ".") OrElse (e.Item.Name = "..") Then
        e.Valid = False
      Else
        listBox1.Items.Add(e.Item.Name)
      End If
    End Sub
    using( FtpConnection connection = new FtpConnection( "ftp.xceed.com" ) )
    {
      connection.ParsingListingLine += new ParsingListingLineEventHandler( this.parsing_line);
      FtpFolder destination = new FtpFolder( connection, "ftp_test" );
      destination.GetItems( true );
    }
    
    private void parsing_line( object sender, ParsingListingLineEventArgs e )
    {
      if( ( e.Item.Name == "." ) || ( e.Item.Name == ".." ) )
      {
        e.Valid = false;
      }
      else
      {
        listBox1.Items.Add( e.Item.Name );
      }
    }
    Requirements

    Target Platforms: Windows 7, Windows Vista SP1 or later, Windows XP SP3, Windows Server 2008 (Server Core not supported), Windows Server 2008 R2 (Server Core supported with SP1 or later), Windows Server 2003 SP2

    See Also