在c#.net中访问没有数据库的文本文件 [英] access text file without database in c#.net

查看:48
本文介绍了在c#.net中访问没有数据库的文本文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

亲爱的先生,

Plz给我回复

假设我想在记事本中添加问题和答案然后在c#.net2008中访问此文件

没有使用任何数据库连接然后如何添加。

plz尽早给我回复。







谢谢和问候

Sarika Nikam

解决方案

我的回答基于你的假设有一个文本文件,你想要阅读和显示内容。



这里有很少的样本。



http://msdn.microsoft.com/en-us/library/vstudio /ezwyzy7b.aspx [ ^ ]

http:// msdn .microsoft.com / EN-US /库/ aa287534(v = vs.71)的.aspx [ ^ ]



如果您对拥有数据源不感兴趣,我的建议是使用XML,因为提取数据会更容易,并且更容易管理问题和答案。


如果您只想阅读文件文本。然后尝试以下行



包含

使用System.IO;

  string  sFileText = File.ReadAllText( 此处的文件路径); 





sFileText包含给定路径文本文件的所有文本,您可以使用sFileText执行任务


Dear Sir,
Plz give me reply
suppose i want to add question and answer in notepad then this file access in c#.net2008
without using any database connection then how to add.
plz give me reply as early as possible.



Thanks & Regards
Sarika Nikam

解决方案

My answer is based on the assumption that you have a text file from which you want to read and display the contents.

Few sample for same are available here.

http://msdn.microsoft.com/en-us/library/vstudio/ezwyzy7b.aspx[^]
http://msdn.microsoft.com/en-us/library/aa287534(v=vs.71).aspx[^]

If you not intrested in haveing datasource my suggestion is to us XML as it will be much easier to extract data and its easier to manage questions and answers.


if you just want to read file text. then try following line

include
using System.IO;

string sFileText = File.ReadAllText("your file path here");



sFileText contain all text of your give path text file, you can perform your task using sFileText


这篇关于在c#.net中访问没有数据库的文本文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆