从文本文件中获取连接字符串 [英] Get Connection String From Text File

查看:61
本文介绍了从文本文件中获取连接字符串的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在创建Windows应用程序(C#),因为我想从文本文件中获取连接字符串......

请帮我讲一下......

I am Creating Windows application(C#) in that I want to get Connection String from text file ......
Please help me regarding same...

推荐答案

您应该使用 FileStream类 [ ^ ]和< a href =http://msdn.microsoft.com/en-us/library/system.io.streamreader.aspx> StreamReader类 [ ^ ]从文本文件中读取数据。



请参阅以下文章,例如:

如何使用C#FileStream类 [ ^ ]

FileStream Open文件[C#] [ ^ ]

C#StreamReader [ ^ ]

如何:从文件中读取文本 [ ^ ]





--Amit
You should use FileStream Class[^] and StreamReader Class[^] to read the data from a text file.

Refer the articles below for example:
How to use C# FileStream Class[^]
FileStream Open File [C#][^]
C# StreamReader[^]
How to: Read Text from a File[^]


--Amit


此代码可以帮助你:



This code can help you:

string connStr = System.IO.File.ReadAllText("filename.txt"); 





更改 filename.txt info您的文件名称。

然后, connStr 包含文件的内容。



Change filename.txt info the name of your file.
Then, connStr contains the contents of the file.


这篇关于从文本文件中获取连接字符串的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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