我尝试使用Curl从Artifactory下载一个.zip文件。为此我使用
System.Diagnostics.Process()
有没有一种方法可以查看下载进度,或者有没有比我使用的方法更好的方法从Artifactory获取.zip文件?以下是我正在使用的代码,感谢任何改进建议
System.Diagnostics.Process process = new System.Diagnostics.Process()
{
StartInfo = new System.Diagnostics.ProcessStartInfo()
{
FileName = "curl",
Arguments = "-H \"X-JFrog-Art-Api:<Token>\" -X GET \"" + url + "\" -O \"" + path + "\"",
UseShellExecute = false,
CreateNoWindow = true,
RedirectStandardOutput = true
}
};
process.Start();
System.IO.StreamReader reader = process.StandardOutput;
string output = reader.ReadToEnd();
process.WaitForExit();
1条答案
按热度按时间cu6pst1q1#
您应该像这样使用HttpClient和HttpRequestMessage:
(from(第10页)
您可以将其更改为await + SendAsync,如果您要进行多个调用,请使用HttpFactory或使客户端成为静态的。