C#运行时编译编辑变量 [英] C# runtime compiling editing variable
问题描述
嘿,我正在做一个小项目,其中包括每20分钟将报告发送到一个电子邮件地址,并且我打算发布它.
由于它将被公开,因此我必须弄清楚如何使用户键入自己的电子邮件地址,然后进行编译.该应用程序的GUI在这里不起作用,这就是为什么我希望另一个应用程序编译第二个应用程序运行时的原因.
我不想在编译时看到整个源代码,只有我要更改的变量.
有人对我有任何提示/示例吗?
在此先感谢.
Hey , I''m working on a little project that includes sending a report to an e-mail address every 20 minutes , and I''m planning to release it.
Since it''s gonna be made public , I have to figure out how to get the user to type in his own e-mail address and then compile. A GUI for the application wouldn''t work here, which is why i would like another app to compile my second app runtime.
I do not want the whole source code visible when compiling , only the variables i want to change.
Does anyone have any tips/examples for me?
Thanks in advance.
推荐答案
为什么在执行应用程序时不将电子邮件地址存储在文本文件中并从那里读取?在这种情况下,更复杂的事情将是IMO的过大杀伤力.
有关如何从此处读取文本文件的示例:
http://msdn.microsoft.com/en-us/library/db5x7c0d.aspx [ ^ ]
[由LP添加]
Why not store the e-mail address in a text file and read it from there when the application is executed? Anything more complicated would be overkill in this case IMO.
Examples on how to read from a text file here:
http://msdn.microsoft.com/en-us/library/db5x7c0d.aspx[^]
[Added by LP]
string fileText=File.ReadAllText(path);
可能就是您所需要的;如果没有(有效)文件,请不要忘记添加错误处理,默认值或错误消息.
[/ADDED]
may be all you need; don''t forget to add error handling, and a default value, or an error message, in case no (valid) file is present.
[/ADDED]
这篇关于C#运行时编译编辑变量的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!