简体   繁体   English

包括自述文件到编译程序

[英]Including readme file to the compiled program

I have a small code that does some recalculations using text data provided. 我有一个小代码,可以使用提供的文本数据进行一些重新计算。 I also have written a readme file with the description of features and 'how-to' instructions. 我还编写了一个自述文件,其中包含功能说明和“操作方法”说明。 The main idea is to make the program standalone that is only one .exe file. 主要思想是使程序成为仅一个.exe文件的独立程序。

I did some googling, but found only how to work with external files or create installers. 我做了一些谷歌搜索,但只发现了如何使用外部文件或创建安装程序。

The question is how to include a text file into the compiled .exe file and how to open it with a button click. 问题是如何将文本文件包含到已编译的.exe文件中,以及如何通过单击按钮将其打开。

So far I found how to embed a resource and read it as a stream using Assembly.GetExecutingAssembly().GetManifestResourceStream(resourceName) . 到目前为止,我发现了如何使用Assembly.GetExecutingAssembly().GetManifestResourceStream(resourceName)嵌入资源并将其作为流读取。
Though, when I try read it through StreamReader it returns System.ArgumentNullException 但是,当我尝试通过StreamReader读取它时,它返回System.ArgumentNullException

Stream streamS = Assembly.GetExecutingAssembly().GetManifestResourceStream(ProjectName.Properties.Resources.Readme); StreamReader rdr = new StreamReader(streamS); string text = rdr.ReadToEnd();

Add it as an Embedded Resource. 将其添加为嵌入式资源。 You can then access it with Assembly.GetManifestResourceStream . 然后,您可以使用Assembly.GetManifestResourceStream对其进行访问。 If you want to show it in a window in your application, that's sufficient; 如果要在应用程序的窗口中显示它,那就足够了; if you want to open it in an external program, like Notepad, you'll have to extract it to a temporary file ( Path.GetTempFileName ), then start Notepad.exe with Process.Start . 如果要在外部程序(如记事本)中打开它,则必须将其解压缩到一个临时文件( Path.GetTempFileName ),然后使用Process.Start启动Notepad.exe。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 WinForms,.NET-读取已编译程序中的设置文件 - WinForms, .NET - reading settings file in compiled program 包括编译查询中的“离线”代码 - including “offline” code in compiled querys 在程序文件中包含SQL用户(具有有限权限)的安全隐患 - Security Implications of Including SQL User (with limited permissions) Within the Program File 将.NET C#程序集成到已编译的(非托管)C ++程序中(无需执行单独的.exe文件) - Integrating a .NET C# program into a compiled (unmanaged) C++ program (without having to execute a separate .exe file) 一般来说,使用IDE编译时,程序的文件大小是否比普通文本编辑器保存的大? - Does a program, in general, have a larger file size when compiled with an IDE than saved by a normal text editor? CSHTML文件不再编译 - CSHTML file is not compiled anymore 编译文件中的已编译类 - Compiled class in compiling file 部署程序,包括外部库 - deploy program including external libraries 如何在 README 文件中将链接显示为纯文本 - How do I display a link as plain text in a README file 无法正确实现 README 文件中的代码隐藏 - Can't implement the code-behind from the README file correctly
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM