如何读取从应用指南文本文件的文本文件 [英] How to read the text file from the Application Directory text file

查看:243
本文介绍了如何读取从应用指南文本文件的文本文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在应用程序项目的类路径目录Windows窗体应用程序中的文本文件。现在,在安装的时候,我想写一个文本值到文本文件中。下面是文本文件,我的Installer类代码..

I have a text file in the application project classpath Directory of Windows Form Application. Now at the time of installation I am trying to write a text value into the text file. Here is my Installer class code for text file..

File.WriteAllText(AppDomain.CurrentDomain.BaseDirectory + @"\" + "ConnectionString.txt",param3);



安装后,我希望检索在ConnectionString.txt文件,并使用输入的文本在应用程序中,但我没有得到如何检索出现在文本文件中的文本值。

After installation I want to retrieve the text that is entered in the "ConnectionString.txt" file and use it in the application but I am not getting how to retrieve the text value present in the text file.

推荐答案

试试下面的代码段

Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "ConnectionString.txt")

阅读的文本文件

string result = File.ReadAllText(Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "ConnectionString.txt"));

这篇关于如何读取从应用指南文本文件的文本文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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