How to read the text file from the Application Dir

2019-06-06 13:06发布

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);

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.

1条回答
太酷不给撩
2楼-- · 2019-06-06 13:34

try the following code snippet

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

Read Text File

string result = File.ReadAllText(Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "ConnectionString.txt"));
查看更多
登录 后发表回答