2013-10-24 2 views
1

.doc, .text 등의 파일을 찾아 textbox3.text에 붙여 넣으려고합니다. 나는 밑줄을 긋고 있는데 무엇을 놓쳤는 지 모른다. 여기C# 파일을 textbox.text 전용 .doc .txt 등으로 찾아보기

코드입니다 :

private void button2_Click(object sender, EventArgs e) 
{ 
    OpenFileDialog bDialog = new OpenFileDialog(); 
    bDialog.Title = "Open Word or Text File"; 
    bDialog.Filter = "Text Files|*.doc;*.docx;*.txt;*.text"; 
    bDialog.InitialDirectory = @"C:\"; 
    if (bDialog.ShowDialog() == DialogResult.OK) 
    { 
    File2Lines = System.IO.File.ReadAllLines(bDialog.FileName.ToString()); 
    } 
    textBox3.Text = File2Lines; 
} 

및 이미지 밑줄과 : http://shrani.si/f/3J/bu/2ALFViEN/missing.png

모든 솔루션? (뭔가 의미가 없으면 나는 멍청하기 때문에)

답변

3

File2Lines을 변수로 선언하지 않았습니다. 또한 ReadAllLinesString[]을 반환하고 string은 반환하지 않습니다. 시도 :

string[] File2Lines = System.IO.File.ReadAllLines(bDialog.FileName.ToString()); 

다음

textBox3.Lines = File2Lines; 
+1

@TimSchmelter를 - 이미지가 선언되지 않은 나타내는 물결에 빨간색. – Steve