当前位置:网站首页>C write TXT file
C write TXT file
2022-07-02 02:13:00 【weixin_ forty million nine hundred and thirty-eight thousand th】
Reference resources Reference article
for(int i=0;i<10;i++)
{
FileStream stream= File.Create("d:\\"+i+".txt");
StreamWriter write = new StreamWriter(stream);
write.Write("aaaa");
write.Close();
write.Dispose();
}
private void button3_Click(object sender, EventArgs e)
{
if (wenpath != null && wenpath != "")
{
string qunp;
db b = new db();
// Create connection string
string path = wenpath;
//string databaseFileName = "C:/QQ.db";
//string connectionString = "data source = " + databaseFileName;
// Linked database
//SQLiteConnection dbConnection = new SQLiteConnection(connectionString);
// Open database
//dbConnection.Open();
//sql sentence
string sql = "select name from sqlite_master where type='table' order by name;";
// load sql
SQLiteCommand cd = new SQLiteCommand(sql, b.lian(path));
// perform
SQLiteDataReader dr = cd.ExecuteReader();
//
// Query all table names
while (dr.Read())// Read
{
try
{
//Console.Write(dr["name"]+"\n");
string str = dr["name"].ToString();
if (str.Length > 12)// Filter less than 9 Table name of , Because the table names of user messages and group messages are greater than 9
{
qunp = str.Substring(0, 12);
string pan = str.Substring(0, 9);
//Console.Write(pan + "\n" + " I am a ");
if (pan == "tb_c2cMsg")
{
// Determine whether it is a user message or a group message
string pp = str;
//string str1 = dr["name"].ToString();
//string pan1 = str1.Substring(0, 9);
//Console.Write(str + "\n");
string sqls = "select * from '" + str + "';";
// load sql
SQLiteCommand cds = new SQLiteCommand(sqls, b.lian(path));
// perform
SQLiteDataReader drs = cds.ExecuteReader();
if (drs.Read())// Read
{
string count;
string sqlc = "select count(*) as num from '" + str + "';";// Get the number of messages
// load sql
SQLiteCommand cdsc = new SQLiteCommand(sqlc, b.lian(path));
// perform
SQLiteDataReader drc = cdsc.ExecuteReader();
if (drc.Read())
{
count = drc["num"].ToString();
//Console.Write(count+"\n");
}
//Console.Write(drs["uin"]);
DateTime d = TimeZone.CurrentTimeZone.ToLocalTime(new DateTime(1970, 1, 1));// Turn the timestamp to mm / DD / yyyy
long t = long.Parse(drs["time"] + "0000000");
TimeSpan to = new TimeSpan(t);
//Console.Write(d.Add(to) + "\n");
var time6 = d.Add(to);
ListViewItem lt = new ListViewItem();
// Convert database data into ListView A row of data of type
lt.Text = drs["uin"].ToString();
lt.SubItems.Add(time6.ToString());
lt.SubItems.Add(drc["num"].ToString());
// take lt Data added to listView1 Control
listView1.Items.Add(lt);
}
}
else if (qunp == "tb_TroopMsg_" && str.Length > 16)// The filter table name starts with troopm But less than 12 Characters , Because this is not a table with content
{
// It's a group message
//if (str.Length > 16 && qunp == "tb_TroopMsg_")
//{
string qun;
try
{
Console.Write(str + ".." + str.Length + "\n");
//string pan1 = str.Substring(9, 12);
qun = str.Substring(12);
Console.Write(qun + "\n");
}
catch (Exception e2)
{
Console.Write(e2 + " Group Fault ");
}
//}
string pp = str.Substring(0, 12);
if (pp == "tb_TroopMsg_" && str.Length > 12)
{
//string pan1 = str.Substring(0, str.Length);
//Console.Write(pan1 + "\n"+str.Length+"\n");
//string qun = str.Substring(4, str.Length);
//Console.Write(str+"\n");
string sqls = "select * from '" + str + "';";
// load sql
SQLiteCommand cds = new SQLiteCommand(sqls, b.lian(path));
// perform
SQLiteDataReader drs = cds.ExecuteReader();
if (drs.Read())// Read
{
string count;
string sqlc = "select count(*) as num from '" + str + "';";// Get the number of messages
// load sql
SQLiteCommand cdsc = new SQLiteCommand(sqlc, b.lian(path));
// perform
SQLiteDataReader drc = cdsc.ExecuteReader();
if (drc.Read())
{
count = drc["num"].ToString();
//Console.Write(count+"\n");
}
//Console.Write(drs["uin"]);
DateTime d = TimeZone.CurrentTimeZone.ToLocalTime(new DateTime(1970, 1, 1));// Turn the timestamp to mm / DD / yyyy
long t = long.Parse(drs["MsgTime"] + "0000000");
TimeSpan to = new TimeSpan(t);
//Console.Write(d.Add(to) + "\n");
var time6 = d.Add(to);
ListViewItem lt = new ListViewItem();
// Convert database data into ListView A row of data of type
lt.Text = " Group " + str.Substring(12);
lt.SubItems.Add(time6.ToString());
lt.SubItems.Add(drc["num"].ToString());
// take lt Data added to listView1 Control
listView1.Items.Add(lt);
}
}
//string str1 = dr["name"].ToString();
//string pan1 = str1.Substring(0, 9);
//Console.Write(str + "\n");
// pan1 = pp.Substring(0, pp.Length);
//Console.Write(pan1+"\n");
}
else
{
Console.Write(str + " Group mismatch ");
}
}
else
{
Console.Write(str + " User messages do not match ");
}
}
catch (Exception e1)
{
Console.Write(e1 + " The following error ");
}
}
}
else
{
MessageBox.Show(" I haven't chosen the corresponding QQ.db file ");
}
}
边栏推荐
- [Video] visual interpretation of Markov chain principle and Mrs example of R language region conversion | data sharing
- how to come in an investnent bank team
- Sword finger offer 62 The last remaining number in the circle
- How to execute an SQL in MySQL
- 医药管理系统(大一下C语言课设)
- leetcode2312. 卖木头块(困难,周赛)
- How to solve MySQL master-slave delay problem
- [技术发展-21]:网络与通信技术的应用与发展快速概览-1- 互联网网络技术
- Open那啥的搭建文档
- As a software testing engineer, will you choose the bank post? Laolao bank test post
猜你喜欢
How to turn off debug information in rtl8189fs
【带你学c带你飞】3day第2章 用C语言编写程序(练习 2.3 计算分段函数)
【OpenCV】-5种图像滤波的综合示例
leetcode2311. 小于等于 K 的最长二进制子序列(中等,周赛)
Opencascade7.6 compilation
A quick understanding of analog electricity
Selection of field types for creating tables in MySQL database
leetcode373. 查找和最小的 K 对数字(中等)
Infix expression to suffix expression (computer) code
[技术发展-21]:网络与通信技术的应用与发展快速概览-1- 互联网网络技术
随机推荐
[question] - why is optical flow not good for static scenes
SQL server calculates the daily average and annual average of the whole province
how to come in an investnent bank team
MySQL operates the database through the CMD command line, and the image cannot be found during the real machine debugging of fluent
essay structure
Automatically browse pinduoduo products
1222. Password dropping (interval DP, bracket matching)
[Video] Markov chain Monte Carlo method MCMC principle and R language implementation | data sharing
What are the necessary things for students to start school? Ranking list of Bluetooth headsets with good sound quality
leetcode2311. 小于等于 K 的最长二进制子序列(中等,周赛)
【毕业季】研究生学长分享怎样让本科更有意义
Five skills of adding audio codec to embedded system
C language 3-7 daffodils (enhanced version)
Volume compression, decompression
pytest 测试框架
Sword finger offer 29 Print matrix clockwise
如何用一款产品推动「品牌的惊险一跃」?
MySQL主从延迟问题怎么解决
STM32F103——两路PWM控制电机
MySQL view concept, create view, view, modify view, delete view