Bonjour,
j'ai ce code qui fonctionne bien en winform mais quand je l'implémente dans globalasax alors il ne réagit plus positivement. après introspection je me suis rendu compte que c'est au niveau de que ça coince. comment pourrais je contourner ce problème d'autorisations. voici le code
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
 this.mutex = new Mutex();
 
 
            try
            {
                string mypath = System.Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments);
 
                string myfile = "testipadd.json";
                string pat = System.IO.Path.Combine(mypath, myfile);
 
                //string ville;
                //string Region;
                //string Pays;
                //string société;
 
                WebClient webClient = new WebClient();
 
 
 
                if (!System.IO.File.Exists(pat))
                {
                    this.mutex.WaitOne();
                    System.IO.FileStream fs = System.IO.File.Create(pat);
                    this.mutex.ReleaseMutex();
                    fs.Close();
 
                    webClient.DownloadFileAsync(new Uri(uri), pat);
                    Thread.Sleep(1000);
 
                    using (StreamReader r = new StreamReader(pat))
                    {
                        string json = r.ReadToEnd();
                        //dynamic items = JsonConvert.DeserializeObject<List<Item>>(json);
                        dynamic array = JsonConvert.DeserializeObject(json);
                        ville = array.city;
                        Region = array.regionName;
                        Pays = array.country;
                        société = array.org;
 
 
                    }
 
                    application.Metier.savecondevice(getipvalue(out ipadd), ville, Region, Pays, société);
                }
                else
                {
                    System.IO.File.Delete(pat);
                    this.mutex.WaitOne();
                    System.IO.FileStream fs = System.IO.File.Create(pat);
                    this.mutex.ReleaseMutex();
 
                    fs.Close();
                    // System.Windows.Forms.MessageBox.Show("Test");
                    webClient.DownloadFileAsync(new Uri(uri), pat);
                    //System.Windows.Forms.MessageBox.Show("Test2");
                    //Thread thread = new Thread();
                    Thread.Sleep(1000);
 
                    using (StreamReader r = new StreamReader(pat))
                    {
                        string json = r.ReadToEnd();
                        //dynamic items = JsonConvert.DeserializeObject<List<Item>>(json);
                        dynamic array = JsonConvert.DeserializeObject(json);
                        ville = array.city;
                        Region = array.regionName;
                        Pays = array.country;
                        société = array.org;
 
 
                    }
                    application.Metier.savecondevice(getipvalue(out ipadd), ville, Region, Pays, société);
                }
 
 
            }
            catch (Exception)
            {
 
 
 
                application.Metier.savecondevice(getipvalue(out ipadd), null, null, null, null);
            }
 
        }
Merci d'avance de votre aide
Prisson