線上訂房服務-台灣趴趴狗聯合訂房中心
發文 回覆 瀏覽次數:1474
推到 Plurk!
推到 Facebook!

有關ftp中斷程式一問?

答題得分者是:RaynorPao
Nicole
一般會員


發表:11
回覆:11
積分:4
註冊:2002-08-12

發送簡訊給我
#1 引用回覆 回覆 發表時間:2002-12-07 13:09:46 IP:211.75.xxx.xxx 未訂閱
請問一下, 我用nmftp做了一個圖片上傳的功能, 不過有時因為網路傳輸太慢使得使用者要等待很久, 是否請教一下,若我想再多設一個button能讓使用中斷正在執行的上傳動作 也同時讓 ftp中斷其連結,並且告知使用者己經中斷其連結了。 不知這樣的中斷程式要如何撰寫呢?之前有試過break 或 abort...等等的動作 但是還是行不通。 謝謝...
RaynorPao
版主


發表:139
回覆:3622
積分:7025
註冊:2002-08-12

發送簡訊給我
#2 引用回覆 回覆 發表時間:2002-12-07 19:23:24 IP:61.221.xxx.xxx 未訂閱
引言: 請問一下, 我用nmftp做了一個圖片上傳的功能, 不過有時因為網路傳輸太慢使得使用者要等待很久, 是否請教一下,若我想再多設一個button能讓使用中斷正在執行的上傳動作 也同時讓 ftp中斷其連結,並且告知使用者己經中斷其連結了。 不知這樣的中斷程式要如何撰寫呢?之前有試過break 或 abort...等等的動作 但是還是行不通。
Nicole 你好: 請參考以下的做法 (
------
-- 若您已經得到滿意的答覆,請適時結案!! --
-- 欲知前世因,今生受者是;欲知來世果,今生做者是 --
-- 一切有為法,如夢幻泡影,如露亦如電,應作如是觀 --
turboted
版主


發表:95
回覆:754
積分:452
註冊:2002-07-23

發送簡訊給我
#3 引用回覆 回覆 發表時間:2002-12-08 08:11:46 IP:61.216.xxx.xxx 未訂閱
在NMFTP裏....Disconnect();是中斷連線的方法 而Abort在RFC裏定義的是,中斷指令,也就是結束未完成的指令 會讓你的上傳指令停止,但不會中斷連線 不過很神奇的一點是,我以前在寫ftp program時 Disconnect 也是使用Abort 而不是Disconnect 而且正常的執行 以下這是我以前寫的code讓你參考一下,但那時我是用BCB4 void __fastcall TChild::Disconnect_ButtonClick(TObject *Sender) { ftp->Abort(); FileFlag=false; ftp->LocalFileName = ""; ftp->HostFileName = ""; ftp->HostDirName = ""; StatusBar1->Panels->Items[1]->Text = ""; StatusBar1->Panels->Items[2]->Text = ""; StatusBar1->Panels->Items[4]->Text = ""; ProgressBar1->Position=0; StatusBar1->Panels->Items[5]->Text =""; IsConnect=false; Connect_Button->Enabled =true; DisConnect_Button->Enabled =false; UPDirectory_Button->Enabled =false; Remote_Refresh->Enabled=false; Append_File_Box->Append_File_Resume_Button_Flag=false; Append_File_Box->Append_File_Overwrite_Button_Flag=false; Append_File_Box->Append_File_Skip_Button_Flag=false; Append_File_Box->Append_File_Rename_Button_Flag=false; RemoteView->Items->Clear(); } 再下面的這個是NMFTP關於Disconnect的Example希望對您有幫助 To recreate this example, you will need to create a new blank C Builder application. Drop 2 TButtons, a TNMSMTP, 3 TEdits, and a TMemo on a form. Insert this code into the Button1's OnClick event: void __fastcall TForm1::Button1Click(TObject *Sender) { NMSMTP1->Host = Edit1->Text; NMSMTP1->UserID = Edit2->Text; NMSMTP1->PostMessage->ToAddress->Text = Edit3->Text; NMSMTP1->PostMessage->FromAddress = Edit3->Text; NMSMTP1->PostMessage->Subject = "Test message"; NMSMTP1->PostMessage->Body->Add("This is a test message"); NMSMTP1->PostMessage->Body->Add("If this message is delivered, the Cancel button (Button2) wasn't pressed fast enough"); NMSMTP1->Connect(); } Insert this code into NMSMTP1's OnConnect event: void __fastcall TForm1::NMSMTP1Connect(TObject *Sender) { Memo1->Lines->Add("Connected, sending message"); NMSMTP1->SendMail(); } Insert this code into NMSMTP1's OnSuccess event: void __fastcall TForm1::NMSMTP1Success(TObject *Sender) { Memo1->Lines->Add("Success, you didn't press Button2 fast enough"); if (NMSMTP1->Connected) NMSMTP1->Disconnect(); } Insert this code into Button2's OnClick event: void __fastcall TForm1::Button2Click(TObject *Sender) { Powersock1->Cancel(); } Insert this code into NMSMTP1's OnDisconnect event: void __fastcall TForm1::NMSMTP1Disconnect(TObject *Sender) { Memo1->Lines->Add("Disconnected"); } Example Description: Run the application. Type your E-Mail address into Edit3. Type the Host name or IP Address of your SMTP server into Edit1. If you do not know what this is, ask your network administrator. If you require a user ID when you connect to your SMTP server, type that into Edit2, or else leave it blank. When you have done this, click Button1. When the words Connected, sending message appear in Memo1, click Button2. When you click button 2, an exception is raised, and the OnDisconnect event is called, which notifies the user of a disconnect. If Button2 is not pressed before the message is successfully sent, the OnSuccess event adds a line to Memo1 notifying the user that the button was not pressed enough, and calls the Disconnect method to disconnect from the remote host if the client is still connected, as reported by the Connected property.
系統時間:2024-04-16 17:26:11
聯絡我們 | Delphi K.Top討論版
本站聲明
1. 本論壇為無營利行為之開放平台,所有文章都是由網友自行張貼,如牽涉到法律糾紛一切與本站無關。
2. 假如網友發表之內容涉及侵權,而損及您的利益,請立即通知版主刪除。
3. 請勿批評中華民國元首及政府或批評各政黨,是藍是綠本站無權干涉,但這裡不是政治性論壇!