我通过 WEBCLIENT 的 UploadFileAsync 方法,上传一个文件到服务器.我想知道他是否上传成功,我看MSDN如下:
http://msdn.microsoft.com/en-us/library/system.net.uploadfilecompletedeventhandler.aspx
需要一个 回调函数事件 UploadFileCompletedEventHandler 如:
void UploadFileCallback( Object^ /*sender*/, UploadFileCompletedEventArgs^ e )
{
System::Threading::AutoResetEvent^ waiter = dynamic_cast<System::Threading::AutoResetEvent^>(e->UserState);
;
try
{
String^ reply = System::Text::Encoding::UTF8->GetString( e->Result );
Console::WriteLine( reply );
}
finally
{
// If this thread throws an exception, make sure that
// you let the main application thread resume.
waiter->Set();
}
}
我就想问下,要得到文件是否上传成功 是否需要服务器返回一个值,还是我们自己判断? 因为我看到 e->Result 的解释是
获取通过调用 UploadFileAsync 方法启动的数据上载操作的服务器回复。不知道我说的对不对?还是请教下大家 怎么判断是否上传成功!
…|▌'寔堅蔃の/「≯還寔╪.逞蔃﹖