Click here to Skip to main content
15,886,919 members
Home / Discussions / C#
   

C#

 
GeneralRe: network programming Pin
Ennis Ray Lynch, Jr.7-May-13 7:33
Ennis Ray Lynch, Jr.7-May-13 7:33 
GeneralRe: network programming Pin
Richard MacCutchan7-May-13 20:34
mveRichard MacCutchan7-May-13 20:34 
AnswerRe: network programming Pin
Anna King8-May-13 3:19
professionalAnna King8-May-13 3:19 
QuestionEthernet Port C# Pin
Member 100344047-May-13 2:28
Member 100344047-May-13 2:28 
AnswerRe: Ethernet Port C# Pin
Richard MacCutchan7-May-13 2:51
mveRichard MacCutchan7-May-13 2:51 
QuestionSaving objects with Cross-reference Pin
larsp7777-May-13 1:35
larsp7777-May-13 1:35 
AnswerRe: Saving objects with Cross-reference Pin
Eddy Vluggen7-May-13 9:22
professionalEddy Vluggen7-May-13 9:22 
GeneralRe: Saving objects with Cross-reference Pin
larsp7777-May-13 12:14
larsp7777-May-13 12:14 
C#
List<Bok> BookList = new List<Bok>();
List<Kund> CustomerList = new List<Kund>();
static string dir = @"C:\Bibliotek\";
string path = dir + "Kunder.xml";
string path2 = dir + "Books.xml";
XmlSerializer xs = new XmlSerializer(typeof(List<Kund>));
XmlSerializer xs2 = new XmlSerializer(typeof(List<Bok>));



C#
public void sparaKund() //Save customerlist
       {


           using (Stream s = File.Create(path))
           {
               xs.Serialize(s,CustomerList);
           }

           using (Stream s2 = File.Create(path2))
           {
               xs2.Serialize(s2, BookList);
           }


       }


The file is created but is empty.



C#
private void Form1_Load(object sender, EventArgs e) //Load customerlist
       {

           // deserialize to a new list
           if (File.Exists(path))
           {
               using (Stream s = File.OpenRead(path))
               {

                   CustomerList = (List<Kund>)xs.Deserialize(s);
               }
           }

          if (File.Exists(path2))
          {
              using (Stream s2 = File.OpenRead(path2))
              {
                  BookList = (List<Bok>)xs2.Deserialize(s2);
              }
          }

     }

GeneralRe: Saving objects with Cross-reference Pin
Bernhard Hiller7-May-13 22:56
Bernhard Hiller7-May-13 22:56 
GeneralRe: Saving objects with Cross-reference Pin
larsp7778-May-13 2:24
larsp7778-May-13 2:24 
GeneralRe: Saving objects with Cross-reference Pin
Eddy Vluggen8-May-13 6:53
professionalEddy Vluggen8-May-13 6:53 
GeneralRe: Saving objects with Cross-reference Pin
larsp7779-May-13 20:19
larsp7779-May-13 20:19 
GeneralRe: Saving objects with Cross-reference Pin
Eddy Vluggen11-May-13 9:40
professionalEddy Vluggen11-May-13 9:40 
GeneralRe: Saving objects with Cross-reference Pin
larsp77711-May-13 10:57
larsp77711-May-13 10:57 
AnswerRe: Saving objects with Cross-reference Pin
Eddy Vluggen11-May-13 11:02
professionalEddy Vluggen11-May-13 11:02 
GeneralRe: Saving objects with Cross-reference Pin
larsp77711-May-13 11:12
larsp77711-May-13 11:12 
GeneralRe: Saving objects with Cross-reference Pin
Eddy Vluggen11-May-13 22:08
professionalEddy Vluggen11-May-13 22:08 
GeneralRe: Saving objects with Cross-reference Pin
larsp77711-May-13 22:18
larsp77711-May-13 22:18 
GeneralRe: Saving objects with Cross-reference Pin
Eddy Vluggen11-May-13 22:36
professionalEddy Vluggen11-May-13 22:36 
GeneralRe: Saving objects with Cross-reference Pin
larsp77711-May-13 22:59
larsp77711-May-13 22:59 
GeneralRe: Saving objects with Cross-reference Pin
Eddy Vluggen11-May-13 23:17
professionalEddy Vluggen11-May-13 23:17 
GeneralRe: Saving objects with Cross-reference Pin
larsp77711-May-13 23:21
larsp77711-May-13 23:21 
QuestionRe: Saving objects with Cross-reference Pin
Eddy Vluggen12-May-13 1:10
professionalEddy Vluggen12-May-13 1:10 
AnswerRe: Saving objects with Cross-reference Pin
larsp77712-May-13 2:09
larsp77712-May-13 2:09 
AnswerRe: Saving objects with Cross-reference Pin
Eddy Vluggen13-May-13 0:32
professionalEddy Vluggen13-May-13 0:32 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.