录入数据到指定TXT

  FileInfo myFile = new FileInfo(@"C:\temp\zxkc.txt");
            StreamWriter sw = myFile.CreateText();

            string[] strs = { zxck1.Text, zxck1.Text, "900" };
            foreach (var s in strs)
            {
                sw.WriteLine(s);
            }
            sw.Close();
  private void Button1_Click(object sender, RoutedEventArgs e)
        {
        
            for (int i = 0; i < 10; i++)
            {
                
               // int i = Convert.ToInt32(zxck1.Text);
            }
            FileInfo myFile = new FileInfo(@"D:\3.txt");
            StreamWriter sw5 = myFile.CreateText();
            int[] charArray = new int[2];
            charArray[0] = 111;
            charArray[1] = 222;
            // initialize these characters 
         

            string[] strs = { "Good Morning!", "Good Afternoon!" };
            File.WriteAllLines(@"d:\4.txt", strs);
            File.WriteAllLines(@"d:\4.txt", strs, Encoding.ASCII);

            string[] strs1 = File.ReadAllLines(@"d:\4.txt");
            
            MessageBox.Show(strs1[0], "系统提示");
            //string str2 = File.ReadAllText(@"c:\1.txt", Encoding.ASCII);
            string str1 = "Good Morning!"; File.WriteAllText(@"d:\2.txt", str1);
            File.WriteAllText(@"d:\2.txt", str1, Encoding.ASCII);
            //MessageBox.Show(str2, "系统提示");

        }

猜你喜欢

转载自www.cnblogs.com/chenlinghao/p/10367967.html