Occurence d'exception IO innatendue
Hello, L'exception est réellement inattendu dans ce cadre la, surtout qu'elle ne surgit qu'une 1 Fois sur / 3
Voila le code ou sa planque (code remanier un peu pour tester W_w)
Code:
1 2 3 4 5 6
| try
{
StreamReader readP1 = new StreamReader(Application.StartupPath + "\\pdata\\patchlist.php");
readP1.Close();
}
catch { Thread.Sleep(400); StreamReader readP2 = new StreamReader(Application.StartupPath + @"\pdata\patchlist.php"); readP2.Close(); } |
quand a ce fameux patchlist, il provient d'un téléchargement aussi robuste que possible :
Code:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22
| public void Download(Uri url, string path, string status)
{
Program.myform.statusLabel.Invoke((ThreadStart)delegate()
{
Program.myform.statusLabel.Text = "Status :" + status;
});
if (!Directory.Exists(Path.GetDirectoryName(path))) Directory.CreateDirectory(Path.GetDirectoryName(path));
if (File.Exists(path)) File.Delete(path);
WebClient client = new WebClient();
client.DownloadProgressChanged += new DownloadProgressChangedEventHandler(client_DownloadProgressChanged);
client.DownloadFileCompleted += new System.ComponentModel.AsyncCompletedEventHandler(client_DownloadFileCompleted);
DataTreatement.wait = true;
using (WebClient wcDl = new WebClient())
{
try
{
wcDl.DownloadFileAsync(url, path);
}
catch { System.Windows.Forms.MessageBox.Show("EXCEPTION TEST"); }
}
} |