读取文本框中的特定内容并将其放入windowsform中

问题描述 投票:0回答:1

我有几行文本的文本文件。在每一行中有三个必要的信息:用户名,日期和时间。

我通过ListBox将线条添加到StreamReader控件中,并且在该控件上方有一个TextBox控件。我想把用户名放在TextBox,但我不知道如何。

这是代码:

namespace Zeiterfassung
{
    public partial class Uebersicht : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            string sPath = @"C:\VSTO\Projects\Zeiterfassung\Zeiterfassung\obj\Debug\Kommt.txt";

            using (StreamReader sr = new StreamReader(sPath))
            {
                while(!sr.EndOfStream)
                {
                    lb_Kommt.Items.Add(sr.ReadLine());
                }
            }
        }
    }
}

并且txt文件中的行都与此类似:

User: KIV\vischer, Datum: 10.09.2018, Zeit: 10:49

我需要把“KIV \ Vischer”放在TestBox,而不是ListBox

c# asp.net streamreader
1个回答
© www.soinside.com 2019 - 2024. All rights reserved.