首页 > Windows开发 > 详细

winfrom读写txt文件值(短信猫)

时间:2015-12-03 11:41:44      阅读:456      评论:0      收藏:0      [点我收藏+]

技术分享

后台语句:

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.Runtime.InteropServices;
using System.IO;
using System.Text;
using System.Security.Cryptography;
using System.Text.RegularExpressions;

namespace WindowsFormsApplication1
{
    public partial class Form1 : Form
    {
        public Form1()
        {
            InitializeComponent();
        }
        string[] allLine;
        private void Form1_Load(object sender, EventArgs e)
        {
            //读取数据
            string path = @"DMS.txt";
            allLine = File.ReadAllLines(path);
            string[] readText0 = allLine[0].Split(/);
            string[] readText1 = allLine[1].Split(/);
            string[] readText2 = allLine[2].Split(/);
            string[] readText3 = allLine[3].Split(/);
            string[] readText4 = allLine[4].Split(/);
            string[] readText5 = allLine[5].Split(/);
            string[] readText6 = allLine[6].Split(/);
            string[] readText7 = allLine[7].Split(/);
            //其中0为端口号,1为中心号码,2为接收号码,3为数据库ip,4为数据库名,5为用户名,6为密码,7日限短信
            MobPort.Text = readText0[0];
            MobileTele.Text = readText1[0];
            txtRecivePh.Text = readText2[0];
            SMSLimit.Text = readText7[0];
            //string s = "^[0-9]+(.[0-9]{n})?$";//正则表达式
            //Regex reg = new Regex(s);
            //if (!reg.IsMatch(this.textbox1.text))
            //{
            //    MessageBox.Show("请输入数字");
            //}
        }

        private void btnSet_Click(object sender, EventArgs e)
        {
            string path = @"DMS.txt";
            FileStream fs = new FileStream(path, FileMode.OpenOrCreate, FileAccess.ReadWrite);
            StreamWriter sw = new StreamWriter(fs);
            sw.WriteLine(MobPort.Text + "/端口号");
            sw.WriteLine(MobileTele.Text + "/中心号码");
            sw.WriteLine(txtRecivePh.Text + "/接收号码");
            sw.WriteLine(allLine[3]);
            sw.WriteLine(allLine[4]);
            sw.WriteLine(allLine[5]);
            sw.WriteLine(allLine[6]);
            sw.WriteLine(SMSLimit.Text + "/日限短信");
            //sw.writeLine(Label1.text + "\n" + Label2.Text);
            sw.Flush();
            sw.Close();
            fs.Close();
        }
    }
}

 

winfrom读写txt文件值(短信猫)

原文:http://www.cnblogs.com/sizhizhiyue/p/5015389.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!