2013-04-30 58 views
0

我试图用RestSharp异步上传文件。不幸的是我无法让它工作。如果我使用client.Execute()而不是client.ExecuteAsync(),它会起作用。是否可以使用RestSharp执行异步文件上传?

为什么?它是一个错误吗?这是一个缺失的功能吗?这是我的错吗?

这里是我的代码:

string file = "c:\\file.zip"; 

var request = new RestRequest(Method.POST); 
request.AddFile(Path.GetFileName(file), Path.GetFullPath(file)); 
// Params ... 

var client = new RestClient(); 
client.BaseUrl = url; 

// Fails with sth. like TimedOut???? 
client.ExecuteAsync(request, response => {}); 
// Works 
var response = client.Execute(request); 

回答

1

一段时间,我发现,AddFile(字符串名称,字符串路径)和AddFile(字符串名称,字符串路径)失败而AddFile(字符串名称,动作作家后,字符串fileName)与ExecuteAsync()一起使用。

相关问题