0
我想使用HTTP下載文件。我該怎麼做?如何使用CA-VO下載文件
我想使用HTTP下載文件。我該怎麼做?如何使用CA-VO下載文件
我有這樣的進一步調查,並已重新排序我的建議,從上週的結果:
類「CHttp」在VO的「互聯網」圖書館有一個方法的GetFile(the VO 2.5 "what's new" has a brief description on page 10)。雖然我沒有嘗試過。你可能會想是這樣的:
local oSession as CHttp
local lSuccess as logic
oSession := CHttp{}
oSession:ConnectRemote("foo.example.com") // Server domain name
lSuccess := oSession:GetFile("bar/baz.pdf",; // Remote filename
"c:\temp\baz.pdf",; // Local filename
lFailIfAlreadyExists)
oSession:CloseRemote()
// If lSuccess, the file should be downloaded to cLocalFileName.
// I don't know whether the filename arguments should use/or \ for directory separators.
我覺得另一種方法是使用Windows ShellExecute
函數調用哪一個下載文件的外部程序。我找到了一個ShellExecute here的例子。我沒有嘗試過,因爲我目前沒有VO編譯器(或幫助文件!)。我不確定這是否是一種好方法,但我不知道從試圖通過提供惡意文件名來運行惡意命令的人是否安全。但我認爲以下可能工作。它假定您的路徑上有程序curl.exe
(請參閱:curl),該路徑用於下載文件。您可能需要完全路徑curl.exe
。我不知道該文件會默認保存(我想你可以指定標記lpDirectory
參數工作目錄)
local cParameters as string
local cURL:="http://www.example.com/interesting.htm" as string
local cLocalFile:="savefile.html" as string
cParameters := "-o "+cLocalFile+" "+cURL
ShellExecute(NULL /*Window handle*/,;
String2PSZ("open"),;
String2PSZ("curl.exe"),;
String2PSZ(cParameters),;
NULL_PTR /* lpDirectory */,;
SW_SHOWNORMAL)
似乎有一種方法其可以用於啓動外部應用程序