如何从文本文件中提取数据? [英] how to extract data from text file??
本文介绍了如何从文本文件中提取数据?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我正在通过net.socket从服务器向客户端发送文本文件.
在客户端,我需要从文件中提取数据.
我需要执行此操作的代码!
请帮忙.
:confused:
解决方案
嗨
您正在寻找的功能是这个功能吗?
/* -[使用指令] ---------- ----------------------------------------- */ 使用 System.IO; /* -[函数] ------------------- ---------------------------------------- */ /* 函数名称:ReadTxtFile_ToLst 描述:从文本文件中读取数据行以换行并存储 它到列表缓冲区. 访问修饰符:公共 参数:字符串txtFilePath Retval:List< string> */ /* ------------------------ ------------------------------------------------- * / 公共列表< string> ReadTxtFile_ToLst(字符串 txtFilePath) { List< string> returnValue = 新列表< string>(); FileInfo genericFileInfo = 新 FileInfo(txtFilePath); StreamReader sr = genericFileInfo.OpenText(); 字符串 lineContents; 同时(sr.EndOfStream!= 真) { lineContents = sr.ReadLine(); returnValue.Add(lineContents); } sr.Close(); 返回 returnValue; }
关于;-)
什么样的数据?如何在文本文件"中进行编码?
:)
System.IO命名空间
I am sending a text file from server to client through net.socket.
At the client side I need to extract the data from the file.
I need the code to do so!
Kindly help.
:confused:
解决方案
Hi
Is this function what you''re looking for maybee?
/*--[ using directives ]---------------------------------------------------*/ using System.IO; /*--[ Function ]-----------------------------------------------------------*/ /* Function Name : ReadTxtFile_ToLst Description : Reads data line- for line from a text file and stores it to a list buffer. Access Modifier : public Param : string txtFilePath Retval : List<string> */ /*-------------------------------------------------------------------------*/ public List<string> ReadTxtFile_ToLst(string txtFilePath) { List<string> returnValue = new List<string>(); FileInfo genericFileInfo = new FileInfo(txtFilePath); StreamReader sr = genericFileInfo.OpenText(); string lineContents; while (sr.EndOfStream != true) { lineContents = sr.ReadLine(); returnValue.Add(lineContents); } sr.Close(); return returnValue; }
Regards ;-)
What kind of data? How is it encoded in the ''text file''?
:)
System.IO Namespace
这篇关于如何从文本文件中提取数据?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文