ファイルダイアログを開くアプリケーションを作成しました。ファイルを開いてテキストボックスにその内容を表示することができます。 Howvever、私が本当に必要とするファイルからのテキストの3つのブロックがあります。私はこれらのテキストブロックだけを「解析する」ことができる必要があります。私はreadalllinesを使用しました。しかし、どのループを使ってソートするかはわかりません。任意の助けいただければ幸い:テキストのブロックのテキストボックスのテキストファイルから特定のテキスト行を表示するにはどうすればよいですか?
私のコード
private void button1_Click(object sender, EventArgs e)
{
Stream myStream;
OpenFileDialog openFileDialog1 = new OpenFileDialog();
//Setting initial directory to the automated repository
openFileDialog1.InitialDirectory = "\\\\10.2.XXX.XX\\Repository\\AutomatedVersionRepository\\JMN Web Application\\";
// Set filter options and filter index.
openFileDialog1.Filter = "txt files (*.txt)|*.txt|Config files (*.config*)|*.config*";
openFileDialog1.FilterIndex = 2;
openFileDialog1.Multiselect = true;
openFileDialog1.RestoreDirectory = true;
// Call the ShowDialog method to show the dialog box.
//bool? userClickedOK = openFileDialog1.ShowDialog() ==DialogResult.OK;
if (openFileDialog1.ShowDialog() ==System.Windows.Forms.DialogResult.OK)
{
if ((myStream = openFileDialog1.OpenFile()) !=null)
{
string strfilename = openFileDialog1.FileName;
string []filetext = File.ReadAllLines(strfilename);
foreach (string line in File.ReadLines(strfilename))
{
//process the line
}
//richTextBox1.Text = filetext;
}
例:
<!---Interface URLS and settings-->
<add key="IUFUploadPath" value="" />
<add key="JSDskAPIURL" value="http://api.documentation.com/16_4" />
<add key="PvAPIURL" value="http://devapi.documentation.com/16_4" />
<add key="FirstDataWebServiceURL" value="https://dev.SpectrumRetailNet.Com/PPSAPI" />
<add key="ReportServerUrl" value="https://reports64.documentation.com/9_2_0/FrameHost.aspx" />
<add key="HelpassAdminUrl" value="http://Helpppass.documentation.com/app/AdminConsole.aspx" />
<add key="XAIMAPIURL" value="//devquippe.documentation.com/ws.aspx" />
これは、XMLのように見える使用するコードですあなたは仕事をはるかに簡単にするxmlクラスを使用する必要があります。 – jdweng