Computer

[C#] OpenFileDialog에서 경로 가지고 오기

창천(蒼天) 2013. 4. 3. 11:30


출처 : http://www.hoons.net/board/qacshap/content/17840

private void openFileDialog1_FileOk(object sender, CancelEventArgs e)
{
    OpenFileDialog dlg = openFileDialog1;

    string fullPathName = dlg.FileName;
    string fileName = dlg.SafeFileName;
    string pathName = fullName.Substring(0, (fullPathName.Length - fileName.Length));

    textBox1.Text = fullPathName; // 전체경로와파일명과확장자
    textBox2.Text = fileName; // 파일명과확장자
    textBox3.Text = pathName; // 전체경로
}