バーコードを使用してアイテムに関連する情報を保存するプロジェクトを作成しています。バーコードごとに、その情報を含むテキスト ファイルがあります。たとえば、バーコード 0000000025 のすべての情報は、0000000025.txt というファイルに保存されています。バーコードをテキストボックスに入力できるようにしたいのですが、バーコードに基づいてどのファイルから読み取るかを StreamReader に伝えます。300 if else ステートメントを次のように手作業でコーディングする代わりに:StreamReader("C:\\ITRS_equipment_log\\0000000025.txt");
それを伝える方法はありますか
StreamReader("C:\\ITRS_equipment_log\\"*pull the barcode from the first textbox and put it here*".txt");
ありがとう
private void buttonSubmit_Click(object sender, EventArgs e)
{
if (!String.IsNullOrEmpty(textBox1.Text))
{
textBox1.SelectionStart = 0;
textBox1.SelectionLength = textBox1.Text.Length;
TextReader textReader = new StreamReader("C:\\ITRS_equipment_log\\0000000025.txt");
//model textbox receives the model of equipment associated with barcode in the text file
modelTextbox.Text = textReader.ReadLine();
//serial textbox receives the serial number of equipment associated with barcode in the text file
serialTextbox.Text = textReader.ReadLine();
//history textbox receives the history of equipment associated with barcode in the text file
historyTextbox.Text = textReader.ReadToEnd();
textReader.Close();
}
}