IdentifiantMot de passe
Loading...
Mot de passe oublié ?Je m'inscris ! (gratuit)
Navigation

Inscrivez-vous gratuitement
pour pouvoir participer, suivre les réponses en temps réel, voter pour les messages, poser vos propres questions et recevoir la newsletter

VC++ .NET Discussion :

[Débutant] Problème de sérialisation collection


Sujet :

VC++ .NET

  1. #1
    Membre confirmé
    Inscrit en
    Avril 2006
    Messages
    65
    Détails du profil
    Informations forums :
    Inscription : Avril 2006
    Messages : 65
    Par défaut [Débutant] Problème de sérialisation collection
    Voici mon 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
    private: System::Void label2_Click_1(System::Object^  sender, System::EventArgs^  e) {
    			IEnumerator^ myEnum = this->_listeNote->GetEnumerator();
    			this->label3->Text = " ";
    			int nb =0;
    			noteSave ^ noteS = gcnew noteSave();
    			//String ^chaine;
    			while ( myEnum->MoveNext() )
    			{
    				note^ not = safe_cast<note^>(myEnum->Current);
    				this->label3->Text += " " + not->existe.ToString(); 
    				if (not->existe == false){
    					this->_listeNote->Remove(not);
    					this->tabNoteS->listeNoteS->Add(not);
    				}
    			}
    			myEnum = this->_listeNote->GetEnumerator();
    			while ( myEnum->MoveNext() )
    			{
    				note^ not = safe_cast<note^>(myEnum->Current);
    				noteS->B = not->couleurnote.B;
    				noteS->G = not->couleurnote.G;
    				noteS->R= not->couleurnote.R;
    				noteS->heigth = not->Height;
    				noteS->width = not->Width;
    				noteS->locationX = not->Location.X;
    				noteS->locationY = not->Location.Y;
    				noteS->titre = not->titlenote;
    				noteS->texte = not->richTextBox1->Text;
    				this->tabNoteS->listeNoteS->Add(noteS);
    			}
    			System::String ^ chaine = "cool";
    			System::Xml::Serialization::XmlSerializer ^ sr;
    			try{
    				sr = gcnew System::Xml::Serialization::XmlSerializer(tabNoteSave::typeid);
    				chaine += " oui ";
    			}
    			catch (Exception ^ e)
    			{
    				System::String ^ message = 	e->InnerException->Message->ToString();
    				chaine += " non ";
    			}
    			System::IO::StreamWriter ^ writer2 = gcnew System::IO::StreamWriter("noteSave.xml");
    			try
    			{
    				sr->Serialize(writer2,this->tabNoteS );
    				chaine += " yeah ";
    			}
    			catch (Exception ^ e)
    			{
    				System::String ^ message = 	e->InnerException->Message->ToString();
    				chaine+=  " " +message;
    			}
    			this->label3->Text = chaine;
     
    		 }
    En fait, ça me sérialise un n fois la même notS. Comment remédier a mon problème?

    Merci

  2. #2
    Membre confirmé
    Inscrit en
    Avril 2006
    Messages
    65
    Détails du profil
    Informations forums :
    Inscription : Avril 2006
    Messages : 65
    Par défaut
    En fait fallait rajouter : noteS = gcnew noteSave() dans :
    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
    while ( myEnum->MoveNext() )
    			{
    				note^ not = safe_cast<note^>(myEnum->Current);
    				noteS->B = not->couleurnote.B;
    				noteS->G = not->couleurnote.G;
    				noteS->R= not->couleurnote.R;
    				noteS->heigth = not->Height;
    				noteS->width = not->Width;
    				noteS->locationX = not->Location.X;
    				noteS->locationY = not->Location.Y;
    				noteS->titre = not->titlenote;
    				noteS->texte = not->richTextBox1->Text;
    				this->tabNoteS->listeNoteS->Add(noteS);
    				noteS = gcnew noteSave();
    			}
    Désolé de vous emmerder avec mes conneries.

Discussions similaires

  1. [Débutant] Problème Sérialisation/Désérialisation
    Par sorry60 dans le forum Silverlight
    Réponses: 29
    Dernier message: 25/06/2010, 11h34
  2. Réponses: 2
    Dernier message: 28/04/2004, 11h25
  3. [Débutant] Problème de déconnexion d'une page JSP
    Par amal9 dans le forum Servlets/JSP
    Réponses: 12
    Dernier message: 22/01/2004, 13h40
  4. [débutant] Problèmes avec CRegKey
    Par Pedro dans le forum MFC
    Réponses: 4
    Dernier message: 10/11/2003, 15h28
  5. Réponses: 11
    Dernier message: 02/09/2003, 14h20

Partager

Partager
  • Envoyer la discussion sur Viadeo
  • Envoyer la discussion sur Twitter
  • Envoyer la discussion sur Google
  • Envoyer la discussion sur Facebook
  • Envoyer la discussion sur Digg
  • Envoyer la discussion sur Delicious
  • Envoyer la discussion sur MySpace
  • Envoyer la discussion sur Yahoo