큰 파일을 처리하기 전에 프로그래밍 방식으로 다운로드해야합니다. 그렇게하는 가장 좋은 방법은 무엇입니까? 파일이 크므로 강제로 종료 할 수 있도록 특정 시간을 기다려야합니다.C에서 큰 파일을 프로그래밍 방식으로 다운로드하는 방법
WebClient.DownloadFile()에 대해 알고 있습니다. 그러나 강제로 나가기 위해 기다릴 시간을 특정하는 방법이 보이지 않습니다.
try
{
WebClient client = new WebClient();
Uri uri = new Uri(inputFileUrl);
client.DownloadFile(uri, outputFile);
}
catch (Exception ex)
{
throw;
}
또 다른 방법은 ProcessStartInfo를 사용 프로세스 'WaitForExit을 사용하여 명령을 파일을 다운로드 발사 명령 줄 유틸리티 (wget을)를 사용하는 것입니다 강제로 종료하려면 (밀리 INT).
ProcessStartInfo startInfo = new ProcessStartInfo();
//set startInfo object
try
{
using (Process exeProcess = Process.Start(startInfo))
{
//wait for time specified
exeProcess.WaitForExit(1000 * 60 * 60);//wait till 1m
//check if process has exited
if (!exeProcess.HasExited)
{
//kill process and throw ex
exeProcess.Kill();
throw new ApplicationException("Downloading timed out");
}
}
}
catch (Exception ex)
{
throw;
}
더 좋은 방법이 있습니까? 도와주세요. 감사.
이 URI 기능이 도움이 진행 비율을
희망을 알 수있는 다음과 같은 웹 클라이언트의 이벤트와 다음 시도 @BFree 말했듯이
DownloadFileAsync
을 사용할 수 있습니다 ? 그것은 ftp입니까? – t0mm13b