>>991
ユーザーが設定するべき箇所は、KABU+のアカウントIDとパスワードと保存するフォルダの3つです。
フォルダがない、あるいは権限がないと、SearchOldfileNewfileの頭でエラー落ちします。
アカウントか、パスワードが間違ってると、Downloadで落ちます。
こんな感じにtry catchでエラー処理しますとエラー内容が分かります。
private void Download(int date, string url, string filename)
{
var uri = new Uri(url);
try
{
using (var webClient = new System.Net.WebClient())
{
webClient.Credentials = new NetworkCredential(SITE_ID, SITE_PASSWORD);
using (var reader = new StreamReader(webClient.OpenRead(url), System.Text.Encoding.GetEncoding("shift_jis")))//アカウントIDやパスワードが間違ってるとここでエラー
{
var line = reader.ReadToEnd();
if (line.Trim() != string.Empty)
{
System.IO.File.WriteAllText(filename, line, System.Text.Encoding.GetEncoding("shift_jis"));
}
}
}
}catch(Exception ex)//エラーが発生するとココに飛んできて、エラー内容がexに入る。
{
Console.WriteLine(ex.Message);//exMessageの内容を読んでエラー対応を検討する
}
}