2010-12-03 11 views
0

なぜこのコードは機能しませんか?WebClientの問題 - なぜ次のコードが機能しないのですか?

WebClient webClient = new WebClient(); 
webClient.Credentials = CredentialCache.DefaultCredentials; 

webClient.DownloadFile(@"http://biblioteca.uqroo.mx/hemeroteca/tesol_quartely/1967_2002_fulltext/", "Vol_01_1.pdf"); 

System.Diagnostics.Process.Start("Vol_01_1.pdf"); 
Console.WriteLine("Worked!"); 

これは、ダウンロードを開始しますが、私はそれは、サイズが破損していると、小さなのファイルを開こうとします。 アドバイスはありますか?

DA

答えて

1

あなたはをリストディレクトリをダウンロードしています。ブラウザで独自のリンクをたどってください。PDFをダウンロードするのではなく、ディレクトリ一覧のみをダウンロードします。ファイル名もURLに入れてください:

WebClient webClient = new WebClient(); 
webClient.Credentials = CredentialCache.DefaultCredentials; 

webClient.DownloadFile("http://biblioteca.uqroo.mx/hemeroteca/" + 
         "tesol_quartely/1967_2002_fulltext/Vol_01_1.pdf", 
         "Vol_01_1.pdf"); 

System.Diagnostics.Process.Start("Vol_01_1.pdf"); 
Console.WriteLine("Worked!"); 
関連する問題