Results 1 to 2 of 2

Thread: StreamWriter Problem

  1. #1

    Thread Starter
    Junior Member
    Join Date
    May 2007
    Posts
    26

    StreamWriter Problem

    Code:
    if (File.Exists("\\Program Files\\ContorPDA\\Apro.xml"))
                    {
                        File.Delete("\\Program Files\\ContorPDA\\Apro.xml");
                    }
                    StreamWriter swc= File.CreateText(@"\Program Files\ContorPDA\Apro.xml");
                    string rez = string.Empty;
                    rez += "<?xml version='1.0'?>" + "\r\n";
                    rez += "<Aparate>" + "\r\n";
                    swc.Write(rez);
                    SqlCeCommand apro = Biblio.pCon.CreateCommand();
                    apro.CommandText = "SELECT  '<Aparat Id=\"'+ CONVERT(nvarchar,id_aparat) + '\" Cafea=\"' + cafea + " +
                                       " '\"  Ciocolata=\"' + ciocolata + " +
                                       " '\" Ceai=\"' + ceai + " +
                                       " '\" Palete=\"' + palete + " +
                                       " '\" Pahare=\"' + pahare + " +
                                       " '\" Lapte=\"' + lapte + " +
                                       " '\" Zahar_personalizat=\"' + zahar_pers + " +
                                       " '\" Zahar=\"' + zahar + " +
                                       " '\" NessCaffe=\"' + nesscaffe + '\" />'" +
                                       " FROM Cantitati ";
                    SqlCeResultSet aproscr = apro.ExecuteResultSet(ResultSetOptions.Scrollable);
                    rez += string.Empty;
                    while (aproscr.Read())
                    {
                      
                       rez += aproscr.GetValue(0) + "\r\n";
                      
                    }
                    
                  
                    rez += "</Aparate>" + "\r\n";
                    swc.Write(rez);
    i use this code to save from sql mobile to xml but it doesn't write ito the file
    I put a breakpoint at the last rez ant it contains the data i need. But it doesnt write,just creates an empty file
    if i put in while swc.Write(rez) it writes into the file but not as i want them to be .What i do wrong?

  2. #2

    Thread Starter
    Junior Member
    Join Date
    May 2007
    Posts
    26

    Re: StreamWriter Problem

    i did it
    i put swc.Close() at the end

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width