各位大哥,请问用C#写过读取.txt文件内容,帮帮忙了,谢谢! txt 文件目录为任意,通过控件选择,<INPUT id="myFile" type="file" size="14" name="myFile" Runat="Server">然后通过控件<asp:ImageButton id="fileImportB" runat="server" ImageUrl="../images/star_26.gif">导入文件内容格式为:
13888000001,一
13888000002,二要求将txt文件内容中满足条件的内容全部读取,并插入数据库
小弟以前没写过,望各位帮忙
13888000001,一
13888000002,二要求将txt文件内容中满足条件的内容全部读取,并插入数据库
小弟以前没写过,望各位帮忙
解决方案 »
- 搞了半天,连个树的节点都没生成,请问错在哪,呜呜呜
- C# socket异步多客户端处理?
- C#控件问题(急需各路大侠帮助!)
- 特转一篇"古"文与兄弟们共勉!无它,不含三聚氰胺,不针对任何具体的人或事,共勉而已!
- 请求C#Winform中怎样保存文件?
- [竹子]问个GDI+问题:Graphics.DrawString()有显明锯齿, 怎么解决?
- 关于窗口重绘性能问题,谢谢解答~!
- System.Drawing.Color类型 如何转换为 System.Drawing.Brush类型
- FormatException: 该字符串未被识别为有效的 DateTime 急求大神修改!!!
- VB.NET有Collection,C#.NET用什么代替?要同时有Key和Index怎么办?
- 数组 二进制数组 转换问题?
- 在c# 中如何去除一个字符串中的空格和‘\t’
if(filePath.PostedFile.FileName != "")
{
txtFilePath =filePath.PostedFile.FileName;
fileExtName = txtFilePath.Substring(txtFilePath.LastIndexOf(".")+1,3); if(fileExtName !="txt" && fileExtName != "TXT")
{
Response.Write("请选择文本文件");
}
else
{
StreamReader fileStream = new StreamReader(txtFilePath,Encoding.Default);
txtContent.Text = fileStream.ReadToEnd();
fileStream.Close();
}
}
dig.Filter = "文本文档(*.txt)|*.txt|所有文件(*.*)|*.*";
if (dig.ShowDialog() == DialogResult.OK)
{
StreamReader reader = new StreamReader(new FileStream(dig.FileName, FileMode.Open), System.Text.Encoding.Default);
string Str = reader.ReadToEnd();
reader.Close();
textBox1.Text = Str; \\这里可以写什么什么什么的什么 = str
13888000002,二
固定格式么?固定格式:要求将txt文件内容中满足条件的内容全部读取,并插入数据库 比较好操作非固定格式
blackhero(黑侠客) 用Excel