请问如何读取一个文本文件,要求一个单词一个单词的读取
解决方案 »
- 高手们有个问题想问问
- <%# Eval("id")%>做为脚本方法的参数会报错!急急急!!!!
- 简单的重命名的问题
- 一个输出缓存的问题
- 新手的提问:怎么样能快点掌握C#语言呢?
- 难难!!!
- 我想用c#三层结构的oa换c#三层结构的全站程序学习。
- asp.net2.0里,要让控件有事件发生,就得设autoposback,但是老是刷屏,还跳动,怎么解决.
- Hashtable删除数据问题
- 急救!!我写的程序当view in browser时,老是提示A page can have only one server-side Form tag
- 如何实现javascript和c#之间的数据共享
- 新闻中的图片在后台是怎么实现的?
http://blog.csdn.net/zhangjian01361/archive/2006/11/08/1373668.aspx
/// 从文本文件中读数据,返回一个数组
/// </summary>
public static string[] GetTextData
{
get
{
string[] result = HttpContext.Current.Cache["Ustbwuyi_ReadTextData_1.0"] as string[];
if (result == null)
{
List<string> list = new List<string>();
using(StreamReader sr=new StreamReader(HttpContext.Current.Server.MapPath("~/App_Data/Provider.txt"),Encoding.UTF8))
{
string str = "";
while ((str = sr.ReadLine()) != null)
{
list.Add(str);
}
result = list.ToArray();
HttpContext.Current.Cache.Insert("Ustbwuyi_ReadTextData_1.0", result, new System.Web.Caching.CacheDependency(HttpContext.Current.Server.MapPath("~/App_Data/Provider.txt")));
}
}
return result;
}
}