当前位置:网站首页>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 ");
}
}
边栏推荐
- 剑指 Offer 42. 连续子数组的最大和
- Email picture attachment
- 1222. Password dropping (interval DP, bracket matching)
- 剑指 Offer 62. 圆圈中最后剩下的数字
- oracle创建只读权限的用户简单四步走
- How to use redis ordered collection
- essay structure
- Design and implementation of key value storage engine based on LSM tree
- 【带你学c带你飞】day 5 第2章 用C语言编写程序(习题2)
- 自动浏览拼多多商品
猜你喜欢

Ar Augmented Reality applicable scenarios

剑指 Offer 62. 圆圈中最后剩下的数字

【带你学c带你飞】1day 第2章 (练习2.2 求华氏温度 100°F 对应的摄氏温度

CSDN article underlined, font color changed, picture centered, 1 second to understand

MySQL view concept, create view, view, modify view, delete view

1222. Password dropping (interval DP, bracket matching)

JMeter (II) - install the custom thread groups plug-in

How to solve MySQL master-slave delay problem

From January 11, 2007 to January 11, 2022, I have been in SAP Chengdu Research Institute for 15 years

leetcode2312. Selling wood blocks (difficult, weekly race)
随机推荐
MySQL operates the database through the CMD command line, and the image cannot be found during the real machine debugging of fluent
"C language programming", 4th Edition, edited by he Qinming and Yan Hui, after class exercise answers Chapter 3 branch structure Exercise 3
Sword finger offer II 031 Least recently used cache
leetcode2309. 兼具大小写的最好英文字母(简单,周赛)
剑指 Offer 29. 顺时针打印矩阵
STM32F103 - two circuit PWM control motor
How to use redis ordered collection
[graduation season] graduate seniors share how to make undergraduate more meaningful
Leetcode face T10 (1-9) array, ByteDance interview sharing
As a software testing engineer, will you choose the bank post? Laolao bank test post
MySQL constraints and multi table query example analysis
Ar Augmented Reality applicable scenarios
No programming code technology! Four step easy flower store applet
Number of palindromes in C language (leetcode)
开发工具创新升级,鲲鹏推进计算产业“竹林”式生长
321. Chessboard segmentation (2D interval DP)
leetcode2311. 小于等于 K 的最长二进制子序列(中等,周赛)
Software No.1
STM32F103——两路PWM控制电机
Pytest testing framework