当前位置:网站首页>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 ");
}
}
边栏推荐
- 附加:信息脱敏;
- leetcode2311. Longest binary subsequence less than or equal to K (medium, weekly)
- 软件开发生命周期 --瀑布模型
- [deep learning] Infomap face clustering facecluster
- The wave of layoffs in big factories continues, but I, who was born in both non undergraduate schools, turned against the wind and entered Alibaba
- MySQL中一条SQL是怎么执行的
- JPM 2021 most popular paper released (with download)
- 研发中台拆分过程的一些心得总结
- OpenCASCADE7.6编译
- Regular expression learning notes
猜你喜欢
随机推荐
new和malloc的区别
Quality means doing it right when no one is looking
【带你学c带你飞】4day第2章 用C语言编写程序(练习 2.5 生成乘方表与阶乘表
[question] - why is optical flow not good for static scenes
Construction and maintenance of business websites [12]
MySQL operates the database through the CMD command line, and the image cannot be found during the real machine debugging of fluent
Types of exhibition items available in the multimedia interactive exhibition hall
Word search applet design report based on cloud development +ppt+ project source code + demonstration video
[technology development -21]: rapid overview of the application and development of network and communication technology -1- Internet Network Technology
【视频】马尔可夫链原理可视化解释与R语言区制转换MRS实例|数据分享
trading
MySQL如何解决delete大量数据后空间不释放的问题
Ar Augmented Reality applicable scenarios
How to use a product to promote "brand thrill"?
剑指 Offer 31. 栈的压入、弹出序列
Golang lock
A quick understanding of analog electricity
The middle element and the rightmost element of the shutter
Spend a week painstakingly sorting out the interview questions and answers of high-frequency software testing / automated testing
Sword finger offer 47 Maximum value of gifts









