-
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?
-
Re: StreamWriter Problem
i did it
i put swc.Close() at the end