全國最多中醫師線上諮詢網站-台灣中醫網
發文 回覆 瀏覽次數:1604
推到 Plurk!
推到 Facebook!

請問使用indy 的IdFTP要如何上傳或下載一個目錄

缺席
anglo
一般會員


發表:11
回覆:7
積分:3
註冊:2003-06-23

發送簡訊給我
#1 引用回覆 回覆 發表時間:2003-09-10 11:40:12 IP:203.70.xxx.xxx 未訂閱
請問各位大大,使用indy 的IdFTP要如何上傳或下載一個目錄(包括裡面的子目錄),在這裡我有找到用delphi寫的,但是我看不懂DelPhi的語法~~謝謝~
RaynorPao
版主


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

發送簡訊給我
#2 引用回覆 回覆 發表時間:2003-09-10 22:19:16 IP:61.221.xxx.xxx 未訂閱
引言: 請問各位大大,使用indy 的IdFTP要如何上傳或下載一個目錄(包括裡面的子目錄),在這裡我有找到用delphi寫的,但是我看不懂DelPhi的語法~~謝謝~
anglo 你好: 你不是有個 Delphi 的範例嗎?? 是否願意貼上來讓小弟我幫你看一看呢?? --
------
-- 若您已經得到滿意的答覆,請適時結案!! --
-- 欲知前世因,今生受者是;欲知來世果,今生做者是 --
-- 一切有為法,如夢幻泡影,如露亦如電,應作如是觀 --
anglo
一般會員


發表:11
回覆:7
積分:3
註冊:2003-06-23

發送簡訊給我
#3 引用回覆 回覆 發表時間:2003-09-11 06:45:55 IP:61.62.xxx.xxx 未訂閱
RaynorPao大大您好~我在http://delphi.ktop.com.tw/topic.php?topic_id=24349 ,看到N/A大大分享了如何從ftp下載*.*的方法,如下 Question/Problem/Abstract: How can I download all files using *.* or other wildcard characters from within Delphi? Answer: You will have to try this out, as I'm at work and can't really do it, but, heh, again, I'm at work. So, I got bored, and wrote this up real quick. If you all find any problems, or have any solutions, please don't hesitate to post.... Anyyyways, without further procrastination, here ya go: Uses WININEt; function TMyFtp.FindFiles: TStringList; var FindData: TWin32FindData; FindHandle: HInternet; Begin FindHandle := FtpFindFirstFile(FFtphandle, '*.*', FindData, 0, 0); If FindHandle = nil Then Begin Result := nil; Exit; End; FCurFiles.Clear; FCurFiles.Add(GetFindDataStr(FindData)); While InternetFindnextFile(FindHandle, @FindData) Do FCurFiles.Add(GetFindDataStr(FindData)); InternetCloseHandle(Findhandle); GetCurrentDirectory; Result := FCurFiles; End; function GetFindDataStr(FindData: TWin32FindData): string; //Get current files in directory var S: string; Temp: string; Begin S := S GetDots(75); Move(FindData.CFilename[0], S[6], StrLen(FindData.CFileName)); Temp := IntToStr(FindData.nFileSizeLow); Move(Temp[1], S[25], Length(Temp)); Result := S; End; function TMyFtp.FindFiles: TStringList; var FindData: TWin32FindData; FindHandle: HInternet; Begin FindHandle := FtpFindFirstFile(FFtphandle, '*.pjl', FindData, 0, 0); If FindHandle = nil then Begin Result := nil; Exit; end; FCurFiles.Clear; FCurFiles.Add(GetFindDataStr(FindData)); While InternetFindnextFile(FindHandle, @FindData) Do FCurFiles.Add(GetFindDataStr(FindData)); InternetCloseHandle(Findhandle); GetCurrentDirectory; Result := FCurFiles; End; function TECU.GetFile(FTPFile, NewFile: string): Boolean; //Download a File Through FTP begin Result := FtpGetFile(FFTPHandle, PChar(FTPFile), PChar(NewFile), False, File_Attribute_Normal, Ftp_Transfer_Type_Binary, 0); end; Procedure Button1.Onclick(); ar MyHandle: HINTERNET; //handle from InternetConnect Begin MyHandle := InternetOpen(`ECU', 0, nil, 0, 0); InternetConnect(MyHandle, ftp://ftp.mysite.com, 0, Anonymouse, user@mysite.com, INTERNET_SERVICE_FTP, INTERNET_CONNECT_FLAG_PASSIVE, 0 ); //Changes to a specific directory once connected TECU.ChangeDirExact('ftp://ftp.mysite.com/downloads'); FindHandle := FtpFindFirstFile(FFtphandle, '*35L.PJL', FindData, 0, 0); // If the directory is blank, then tell me about it. Else, download all. If FindHandle = nil Then Begin Result := nil; ShowMessage('The file was not able to be downloaded. Please Re-Try'); End Else TECU.GetFile('*.*', 'c:\*.*'); End; End; //The call InternetConnect Uses the following function ( included with WinInet ): {******************************************************************************* function InternetConnect( hInet: HINTERNET; // Handle from InternetOpen lpszServerName: PChar; // Server: i.e., www.borland.com nServerPort: INTERNET_PORT; // Usually 0 lpszUsername: PChar; // usually anonymous lpszPassword: PChar; // usually your email address dwService: DWORD; // FTP, HTTP, or Gopher? dwFlags: DWORD; // Usually 0 dwContext: DWORD): // User defined number for callback HINTERNET; stdcall; *******************************************************************************} // Again, this is not 100% concrete to work, so, make it concrete by posting ;) // Thanks
系統時間:2024-03-29 17:58:32
聯絡我們 | Delphi K.Top討論版
本站聲明
1. 本論壇為無營利行為之開放平台,所有文章都是由網友自行張貼,如牽涉到法律糾紛一切與本站無關。
2. 假如網友發表之內容涉及侵權,而損及您的利益,請立即通知版主刪除。
3. 請勿批評中華民國元首及政府或批評各政黨,是藍是綠本站無權干涉,但這裡不是政治性論壇!