usingSystem;usingSystem.Collections.Generic;usingSystem.ComponentModel;usingSystem.Data;usingSystem.Drawing;usingSystem.Text;usingSystem.Windows.Forms;usingSystem.IO;usingsmartdeviceproject1.webreference;usingSystem.Reflection;namespacesmartdeviceproject1{ Public Partial classForm1:form { PublicForm1 () {InitializeComponent (); } StreamWriter SW=NULL; Private voidButton1_Click (Objectsender, EventArgs e) { stringPath =@"\my Documents\ storage. csv";//path to save fileTry { if(path)//If the file has been created {file.exists This. SW =file.appendtext (path); This. SW. WriteLine ("overlay data, 123,"+DateTime.Now.ToShortDateString ()); } Else { This. SW =NewStreamWriter (path);//If not created
This. SW. WriteLine ("new data, 789,"+DateTime.Now.ToShortDateString ()); } } Catch(Exception ex)//exception handling {MessageBox.Show (ex. Message); } finally { //emptying buffers This. SW. Flush (); //Close the stream This. SW. Close (); } } }}
VS2008 test is normal.
WinCE write data to the Csv/txt file