如何从项目中读取文本文件。它只显示项目不在任何文件夹中请紧急帮助我.. [英] How to read the text file from the project. It only show the project not in any folders please help me urgently..

查看:95
本文介绍了如何从项目中读取文本文件。它只显示项目不在任何文件夹中请紧急帮助我..的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想在我的项目中添加一个文本文件。文本文件不显示任何文件夹。该文件只显示项目exe。



我尝试过:



i我试过流阅读器。但是,它不起作用。因为路径无法选择

i would like to add a text file in my project. the text file do not show any folders. the file only show the project exe.

What I have tried:

i am tried stream reader. but, it does'nt work. because path not possible to select

推荐答案

一个想法:你的意思是你把文本文件添加为资源吗?如果是这样,那么您将文本文件内容作为字符串访问。我做了同样的事情:我的修订历史记录是一个文本文件,作为资源加载到我的项目中作为嵌入式资源。

在我的关于表单中,我将其加载到文本中框:

A thought: do you mean you added the text file as a resource? If so, then you access the text file content as a string. I do much the same: my Revision history is a text file which is loaded as a resource into my project as an "Embedded Resource".
In my "About" form, I load it into a text box:
/// <summary>
/// Loading - set up the text fields.
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private void frmAbout_Load(object sender, EventArgs e)
    {
    StringBuilder sb = new StringBuilder();
    sb.AppendFormat("Media Master Version \t{0}\n\n", AssemblyVersion);
    sb.AppendFormat("   AppModule: \t\t{0}\n", MediaMaster.Timestamp.BuildAt);
    sb.AppendFormat("   Presentation layer: \t{0}\n", MediaMasterPL.Timestamp.BuildAt);
    sb.AppendFormat("   Utilities: \t\t{0}\n", UtilityControls.Timestamp.BuildAt);
    sb.AppendFormat("   Video Data Layer: \t{0}\n", VideoDL.Timestamp.BuildAt);
    sb.AppendLine();
    sb.AppendFormat("{0} is {1}\n", AssemblyProduct, AssemblyCopyright);
    string[] lines = sb.ToString().Split('\n');
    tbAboutDetails.Lines = lines;
    lines = Properties.Resources.RevisionHistory.Split('\n');
    tbRevisionHistory.Lines = lines;
    }



猜测,这就是你要做的......


At a guess, that's what you are trying to do...


这篇关于如何从项目中读取文本文件。它只显示项目不在任何文件夹中请紧急帮助我..的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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