private void createSMStxt(string loginfo)
{
//生成txt短信报警
//生成短信txt //第一行手机号码 第二行内容
string smspath = "";
string smstextpath = Properties.Settings.Default.smspath;
if (!Directory.Exists(smstextpath))
{
Directory.CreateDirectory(Application.StartupPath + "\\smstxt");
smspath = Application.StartupPath + "\\smstxt" + "\\" + DateTime.Now.ToString("yyyyMMddHHmmssfff") + ".txt";
}
else
{
smspath = smstextpath + "\\" + DateTime.Now.ToString("yyyyMMddHHmmssfff") + ".txt";
}
System.IO.StreamWriter swfn = System.IO.File.AppendText(smspath);
string writelinetxt = "";
foreach (string mphone in mobilephones)
{
string[] mp = mphone.Split(new string[1] { ";" }, StringSplitOptions.RemoveEmptyEntries); //号码;姓名
writelinetxt = mp[0] + ";" + writelinetxt;
}
swfn.WriteLine(writelinetxt);
swfn.WriteLine(loginfo);
swfn.Flush();
swfn.Close();
}
原文:http://www.cnblogs.com/ssjsk/p/6362531.html