Bonjour,
Je reviens encore vers vous car j'ai besoin d'aide encore et parce que j'ai jamais été déçu de ce site
Donc au départ il fallait que je créé un fichier vCard avec des contact (tout ça ca marche pas de problème), mais on à reçu le téléphone ce matin et sur celui-ci il ne gère pas un répertoire dans un seul .vcf, il faut que je l'ai créé un par un
Je vais donc transformer mon code pour juste ouvrir éventuellement une seule fois la boîte de dialogue pour choisir le répertoire (donc le chemin ou chaque vCard sera enregistrer) mais là et le problème comment faire :/
Voici mon code actuel :
Et voici mes fonctions static que j'utilise au dessus :
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 List<Contact> lesContacts; public Form1() { InitializeComponent(); } private void btn_créer_Click(object sender, EventArgs e) { lesContacts = UtilityVCF.CreateListContacts(rtb_vcf); string fichierVCF = UtilityVCF.TransformersVCF(lesContacts); if (fichierVCF == "Error") { MessageBox.Show("Il n'y a aucun contact"); } else { saveFileDialogVCF.Filter = "Fichier vCard *.vcf|*.vcf"; if (saveFileDialogVCF.ShowDialog() == System.Windows.Forms.DialogResult.OK) { StreamWriter sw = new StreamWriter(saveFileDialogVCF.FileName); sw.AutoFlush = true; sw.Write(fichierVCF); sw.Flush(); sw.Close(); } } }
et voici ma classe contact (au cas ou ):
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 public static string TransformersVCF(List<Contact> listeContacts) { string stringVCF = ""; if (listeContacts.Count < 0) { stringVCF = "Error"; } else { foreach (Contact leContact in listeContacts) { stringVCF = stringVCF + "BEGIN:VCARD" + Environment.NewLine + "VERSION:2.1" + Environment.NewLine + "N:" + leContact._Nom + ";" + leContact._Prenom + Environment.NewLine + "FN:" + leContact._Prenom + " " + leContact._Nom + Environment.NewLine + "TEL;CELL:" + leContact._NumTel + Environment.NewLine + "END:VCARD" + Environment.NewLine; } } return stringVCF; } public static List<Contact> CreateListContacts(RichTextBox rtbContacts) { List<Contact> Contacts = new List<Contact>(); foreach (string ligne in rtbContacts.Lines) { string[] ligneContact = ligne.Split(new Char[] { ' ', '\t' }); string[] leContact = new string[3]; int attribut = 0; foreach (string mot in ligneContact) { if (mot != " ") { leContact[attribut] = mot; attribut += 1; } } Contact unContact = new Contact(leContact[0], leContact[1], leContact[2]); Contacts.Add(unContact); } return Contacts; }
Merci d'avance, si il manque des précision demandé moi
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 class Contact { #region Attribut(s) private string Nom; private string Prenom; private string NumTel; #endregion #region Accesseur(s) public string _Nom { get { return Nom;} } public string _Prenom { get { return Prenom; } } public string _NumTel { get { return NumTel; } } #endregion #region Construteur(s) public Contact(string nom, string prenom, string numTel) { Nom = nom; Prenom = prenom; NumTel = numTel; } #endregion }
Merci d'avance
Cordialement
Foudogue
Partager