GrapeCity Secure FTP for .NET 4.0J
Listing イベント
使用例 

Marshal(Listing,String,Object)が使用されたときに発生します。
シンタックス
<DescriptionAttribute("Raised when Marshal(string, Listing) is used.")>
<CategoryAttribute("Marshaled Data")>
Public Event Listing As EventHandler(Of ListingEventArgs)
[Description("Raised when Marshal(string, Listing) is used.")]
[Category("Marshaled Data")]
public event EventHandler<ListingEventArgs> Listing
イベント データ

イベント ハンドラが、このイベントに関連するデータを含む、ListingEventArgs 型の引数を受け取りました。次の ListingEventArgs プロパティには、このイベントの固有の情報が記載されます。

プロパティ解説
Message Dart.Ftp.UserStateEventArgsから継承されます。Marshalメソッドによって提供されたメッセージ引数を返します。
UserState Dart.Ftp.UserStateEventArgsから継承されます。Marshalメソッドによって提供されたユーザー状態引数を返します。
解説
イベントハンドラでのUIコントロールの更新については、SynchronizingObjectプロパティを参照してください。
使用例
以下のサンプルコードは、FTPリストを取得する方法を示します。 このサンプルコードでは、Startメソッドを使用してgetListing関数をワーカースレッドで実行し、Marshalメソッドを使用してデータをUIスレッドにマーシャリングしています。
private void button1_Click(object sender, EventArgs e)
{
    // FtpSessionを作成し、ワーカースレッドでリストを取得します。
    FtpSession session = new FtpSession();
    session.RemoteEndPoint.HostNameOrAddress = myServer;
    session.Username = myUsername;
    session.Password = myPassword;

    // ワーカースレッドでリストを取得します。
    ftp1.Start(getListing, session);
}
        
private void getListing(object state)
{
    try
    {
        // サーバーにログインしてリストを取得します。
        ftp1.Session = state as FtpSession;
        ftp1.Connect();
        ftp1.Authenticate();
        Listing listing = ftp1.List("", "", ListType.Full);

        // リストをUIスレッドにマーシャリングします。
        ftp1.Marshal(listing, "", null);
    }
    catch (Exception ex)
    {
        ftp1.Marshal(ex);
    }
    finally
    {
        // サーバーからログアウトします。
        ftp1.Close();
    }
}

private void ftp1_Listing(object sender, ListingEventArgs e)
{
    // リストに含まれるすべてのリスト項目をリストボックスに追加します。
    foreach (ListEntry entry in e.Listing)
        listBox1.Items.Add(entry.Text);
}
        
private void ftp1_Error(object sender, ErrorEventArgs e)
{
    MessageBox.Show(e.GetException().Message);
}

private void ftp1_Connection_Log(object sender, DataEventArgs e)
{
    System.Diagnostics.Debug.WriteLine(e.Data.ToString());
}
Private Sub button1_Click(ByVal sender As Object, ByVal e As EventArgs) Handles button1.Click
    ' FtpSessionを作成し、ワーカースレッドでリストを取得します。
    Dim session As FtpSession = New FtpSession()
    session.RemoteEndPoint.HostNameOrAddress = myServer
    session.Username = myUsername
    session.Password = myPassword

    ' ワーカースレッドでリストを取得します。
    ftp1.Start(AddressOf getListing, session)
End Sub

Private Sub getListing(ByVal state As Object)
    Try
        ' サーバーにログインしてリストを取得します。
        ftp1.Session = TryCast(state, FtpSession)
        ftp1.Connect()
        ftp1.Authenticate()
        Dim listing As Listing = ftp1.List("", "", ListType.Full)

        ' リストをUIスレッドにマーシャリングします。
        ftp1.Marshal(listing, "", Nothing)
        Catch ex As Exception
        ftp1.Marshal(ex)
    Finally
        'サーバーからログアウトします。
        ftp1.Close()
    End Try
End Sub

Private Sub ftp1_Listing(ByVal sender As Object, ByVal e As ListingEventArgs) Handles ftp1.Listing
    ' リストに含まれるすべてのリスト項目をリストボックスに追加します。
    For Each entry As ListEntry In e.Listing
        listBox1.Items.Add(entry.Text)
    Next entry
End Sub

Private Sub ftp1_Error(ByVal sender As Object, ByVal e As ErrorEventArgs) Handles ftp1.Error
    MessageBox.Show(e.GetException().Message)
End Sub

Private Sub ftp1_Connection_Log(ByVal sender As Object, ByVal e As DataEventArgs) Handles ftp1.Connection.Log
    System.Diagnostics.Debug.WriteLine(e.Data.ToString())
End Sub
参照

関連項目

Ftp クラス
Ftp メンバ

 

 


© 2002, GrapeCity inc. All rights reserved.