locked
Windows Mobile 5.0 - Help! RRS feed

  • Question

  •  

    I need some code that will take some text from some labels and save it as a textfile on a Windows Mobile 5.0 pda.

     

    Example of textfile:

     

    label1, label2, label3, label4, label5, label6, label7

     

    I need code to save the text and then load it as well.

     

    The app has been created in Visual Studio 2005 using the Windows Mobile 5.0 SDK.

     

    Monday, August 13, 2007 4:08 PM

Answers

  • Hi knxrb,

    I tried a sample code, see below:

    Code Snippet

                string MyFilePath = "\\Program Files\\1.txt";

     

                if (!File.Exists(MyFilePath))

     

                    File.Create(MyFilePath);

                StreamWriter theWriter = new StreamWriter(MyFilePath);

                foreach (Control ctl in this.Controls)

                {

                    if (ctl is Label)

                    {                   

                        theWriter.Write(ctl.Text+",");

                       

                    }

                }

     theWriter.Close();

     

                StreamReader theRead = new StreamReader(MyFilePath);

                string text= theRead.ReadToEnd();

     

     

     

    I hope it helpful to you.

     

    Guang-Ming Bian - MSFT

    Wednesday, August 15, 2007 8:08 AM