Dart.Ftp Namespace > Ftp Class : Listing Event |
Public Event Listing As EventHandler(Of ListingEventArgs)
Dim instance As Ftp Dim handler As EventHandler(Of ListingEventArgs) AddHandler instance.Listing, handler
public event EventHandler<ListingEventArgs> Listing
public: event EventHandler<ListingEventArgs^>^ Listing
The event handler receives an argument of type ListingEventArgs containing data related to this event. The following ListingEventArgs properties provide information specific to this event.
Property | Description |
---|---|
Message | Returns the message argument provided by the Marshal method. (Inherited from Dart.Ftp.UserStateEventArgs) |
UserState | Returns the user state argument provided by the Marshal method. (Inherited from Dart.Ftp.UserStateEventArgs) |
private void getListing() { //Setup the Ftp session and then connect, authenticate, and retrieve a listing on a worker thread ftp1.Session.RemoteEndPoint.HostNameOrAddress = myServer; ftp1.Session.Username = myUsername; ftp1.Session.Password = myPassword; //Wire up the Listing event to receive the listing on the UI thread ftp1.Listing += new EventHandler<ListingEventArgs>(ftp1_Listing); //The Start method executes the listing operation on a worker thread so the UI is not blocked. //Worker thread Exceptions are automatically caught and marshaled to the Error event ftp1.Start(getListingWorker, null); } private void getListingWorker(object state) { try { //Login to a server and get a listing ftp1.Connect(); ftp1.Authenticate(); Listing listing = ftp1.List("", "", ListType.Full); //Marshal the listing to the UI thread ftp1.Marshal(listing, "", null); } finally { //Logout of the server ftp1.Close(); } } private void ftp1_Listing(object sender, ListingEventArgs e) { //Add all the list entries in the listing to a listbox foreach (ListEntry entry in e.Listing) listBox1.Items.Add(entry.Text); }
Private Sub getListing() 'Setup the Ftp session and then connect, authenticate, and retrieve a listing on a worker thread ftp1.Session.RemoteEndPoint.HostNameOrAddress = myServer ftp1.Session.Username = myUsername ftp1.Session.Password = myPassword 'Wire up the Listing event to receive the listing on the UI thread AddHandler ftp1.Listing, AddressOf ftp1_Listing 'The Start method executes the listing operation on a worker thread so the UI is not blocked. 'Worker thread Exceptions are automatically caught and marshaled to the Error event ftp1.Start(AddressOf getListingWorker, Nothing) End Sub Private Sub getListingWorker(ByVal state As Object) Try 'Login to a server and get a listing ftp1.Connect() ftp1.Authenticate() Dim listing As Listing = ftp1.List("", "", ListType.Full) 'Marshal the listing to the UI thread ftp1.Marshal(listing, "", Nothing) Catch ex As Exception ftp1.Marshal(ex) Finally 'Logout of the server ftp1.Close() End Try End Sub Private Sub ftp1_Listing(ByVal sender As Object, ByVal e As ListingEventArgs) 'Add all the list entries in the listing to a listbox For Each entry As ListEntry In e.Listing listBox1.Items.Add(entry.Text) Next entry End Sub