告诉按钮从 VisualC# 中上传的 .txt 文件中解析文本字符串

发布于 2024-12-10 13:22:08 字数 770 浏览 0 评论 0原文

顺便说一句,我是 Visual C# 新手。

我已经有了要上传的 .txt 文件,但是当我更熟悉 Visual C# 后,我的最终目标是将 .txt 文件上传到内存中,读取它,解析其中的数据字符串的某些部分,然后打印数据到网页上。

我一直在网上查找(也许在我说我找不到任何我无法理解的东西之前我应该​​了解更多),但我在 StackOverflow 上注意到,你越具体,就越有可能您将得到详细的答案。

我还注意到这个问题可以在“show me teh codez”下提交。当我正在学习这一切时,我更愿意指出我应该朝哪个方向以及我应该如何处理这个问题,而不是“向我展示代码”。

.txt 文件中的内容

_______________________________
.RES B7=121
.RES C12=554
.RES VMAX=4.7μV
_______________________________

大约另外 50 个或 .RES 都是这样。我想在 while 循环下解析这些,但如果有更有效的方法,请告诉我。

我想要做的是将“=”之前的值解析为标签,减去“.RES”(不要忘记它后面的空格);文本框中“=”后面的值全部来自 clk_btn 事件(在 VS2010 Express 中,单击您希望将其放在设计视图中的按钮,然后在 C# 中弹出该处理程序)。

请记住,这全部来自上传的文本文件。该文件直接上传到我桌面上 VS2010 Express 的默认“WebApplication1”文件夹中。再说一遍,不要“显示代码”,而是给我指点。谢谢各位。

BTW, I'm new at Visual C#.

I've already got the .txt file to upload, but after I get more familiar with Visual C#, my ultimate goal is to upload a .txt file into memory, read it, parse certain parts of data strings on it, and print the data onto the webpage.

I've been looking up and down the web (maybe I should learn more before I say I can't find anything I can't understand), but I've noticed on StackOverflow, the more specific you are, the more of a detailed answer you're going to get.

I also noticed this question could be filed under a "show me teh codez". As I am learning all this, instead of "show me teh codez", I would perfer pointers in which direction I should go and how I should approach this.

Content in the .txt file

_______________________________
.RES B7=121
.RES C12=554
.RES VMAX=4.7μV
_______________________________

It goes on like this for about another 50 or .RES's. I want to parse these under a while loop, but if there is a more efficient way to do so let me know.

What I want to do is parse the value before the "=" into a label, minus the ".RES " (Don't forget the space after it); and the value after the "=" into a textbox, all from a clk_btn event (in VS2010 Express, click on the button you wish to put it under in the design view and up pops the handler in the C# for it).

Remember, this is all from an uploaded text file. The file is uploaded directly into VS2010 Express' default "WebApplication1" Folder on my desktop. Again, prefer not to "show me teh codez", but give me pointers. Thanks folks.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

单挑你×的.吻 2024-12-17 13:22:08

如果所有行都以“.RES”开头,您可以使用 Substring 删除它们。之后,您可以在“=”上拆分字符串以获得两个标记。一种用于标签,另一种用于文本框。创建一个标签并将适当的值设置为两个标记中的第一个。创建一个文本框并使用第二个标记的值设置适当的属性。将它们都添加到父控件的控件集合中。

(由于明确希望不显示代码,因此省略了代码)

If all lines start with ".RES " you can use Substring to remove those. After that you could split the string on the "=" to get two tokens. One for the label and one for the text box. Create a label and set the appropriate value to the first of the two tokens. Create a textbox and set the appropriate property with the value of the second token. Add them both to the control collection of the parent control.

(Code omitted due to the explicit wish of not being shown the code)

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文