Messenger Plus! Live - Scripting Documentation
The MsgPlus::DownloadFile function downloads a file asynchronously
from an ftp, http or https source and generates an event when the download
is complete.
溴>
Messenger Plus! Live -脚本文件
物体的参考-m sgplus
msgplus : : downloadfile
该msgplus : : downloadfile功能下载文件异步
从FTP , HTTP或HTTPS的来源和产生一个事件,当下载
已完成。
该msgplus : : downloadfile功能下载文件异步
从FTP , HTTP或HTTPS的来源和产生一个事件,当下载
已完成。
Syntax
[boolean] DownloadFile(
[string] Url,
[string,optional] OutFile
);
Parameters
- Url
- [string] Address of the file to download. The string must begin
by either "ftp://", "http://" or "https://".
- OutFile
- [string,optional] Full path to the file that will be created to
receive the downloaded data. If no path is specified, Messenger
Plus! automatically generates a unique file name in the user's
temporary directory.
Return Value
A boolean value specifying if the download was initiated. If the
returned value is true, an
OnEvent_DownloadFileComplete
event will be generated once the download operation has completed
(whether it succeeds or not). Here is a list of possible reasons why
this function may return
false:
一个布尔值,指明如果下载发起的。如果
返回值为true , 1
onevent_downloadfilecomplete
活动将产生的,一旦下载运行已完成
(不论它成功与否) 。这里是一个名单,可能的原因
这个函数可能返回
虚假:
一个布尔值,指明如果下载发起的。如果
返回值为true , 1
onevent_downloadfilecomplete
活动将产生的,一旦下载运行已完成
(不论它成功与否) 。这里是一个名单,可能的原因
这个函数可能返回
虚假:
- The specified Url is empty.
- Not enough system resources to complete the operation.
Remarks
It is highly recommended to use this function whenever your script
needs to download a file. This function returns as soon as the download
request is sent to a different thread of execution, guaranteeing that
Messenger will not freeze while the server is being contacted. It is
important as various network issues can occur while downloading a file
on an external server. If the download is done synchronously with
another method, it can result in Messenger freezing for an unspecified
amount of time, blocking the user, disturbing Messenger's own network
communications and giving the impression that the whole application
crashed.
这是非常推荐使用此功能时,您的脚本
需要下载文件。这个函数返回尽快下载
请求被发送到不同的执行绪,保证
信使将不会冻结,而服务器现正联络。它是
重要,因为不同的网络问题都可以发生,而下载档案
对外部服务器。如果下载的是做同步
另一种方法,它可导致在Messenger的冻结为一不明
大量的时间,阻碍用户,令人不安的信使自己的网络
通信和给人一个印象,认为整个应用
坠毁。
这是非常推荐使用此功能时,您的脚本
需要下载文件。这个函数返回尽快下载
请求被发送到不同的执行绪,保证
信使将不会冻结,而服务器现正联络。它是
重要,因为不同的网络问题都可以发生,而下载档案
对外部服务器。如果下载的是做同步
另一种方法,它可导致在Messenger的冻结为一不明
大量的时间,阻碍用户,令人不安的信使自己的网络
通信和给人一个印象,认为整个应用
坠毁。
If no path is specified in OutFile, a temporary
file will be created and its path will be sent in parameter of
OnEvent_DownloadFileComplete. Deleting the temporary file is your
responsibility, Messenger Plus! will not do it automatically.
如果没有指定的路径是在outfile ,一个临时
文件将被创建和它的路径将被派往在参数
onevent_downloadfilecomplete 。删去临时文件是您的
责任,Messenger Plus!不会做,它会自动。
如果没有指定的路径是在outfile ,一个临时
文件将被创建和它的路径将被派往在参数
onevent_downloadfilecomplete 。删去临时文件是您的
责任,Messenger Plus!不会做,它会自动。
Example
Here is an example that shows how to download a file to check for
updates.
这里便是一个例子,说明如何下载档案,以检查
更新。
function DownloadUpdateFile()
{
var Started = MsgPlus.DownloadFile("http://server.com/file.txt");
if(Started)
Debug.Trace("Downloading file, waiting for event");
else
Debug.Trace("Couldn't start the download");
}
function OnEvent_DownloadFileComplete(Url, OutFile, Success)
{
Debug.Trace("DownloadFileComplete event received for " + Url);
Debug.Trace(" Success: " + Success);
if(Success)
{
Debug.Trace(" Result file path: " + OutFile);
//Read the file, do what needs to be done//
//Delete the temporary file
var File = new ActiveXObject("Scripting.FileSystemObject");
File.DeleteFile(OutFile);
}
}
Function Information
| Object |
MsgPlus |
| Availability |
Messenger Plus! Live 4.20 |
See Also
MsgPlus Object,
OnEvent_DownloadFileComplete.
msgplus对象,
onevent_downloadfilecomplete 。
Sponsor
Links
Scripts文档目录
脚本库
FAQ