1. 도구상자에서 "openFileDialgo"를 Form 內 Drag
2. "File Browser" 버튼을 더블 클릭하여 Event 활성화
3. 아래 코드 입력
private void btnFileBrowser_Click(object sender, EventArgs e)
{
tboxFileAddress.Clear();
String file_path = null;
// Current User's Desktop Address
string localpath = Environment.GetFolderPath (Environment.SpecialFolder.Desktop);
openFileDialog1.InitialDirectory = localpath;
// Set openFileDialog's initial address is User's Desktop
if (openFileDialog1.ShowDialog() == DialogResult.OK)
{
// Save the seleted file's path
file_path = openFileDialog1.FileName;
// Display the loaded file name on the textbox
tboxFileAddress.Text = file_path.Split("\\")[file_path.Split("\\").Length - 1];
}
}
'둘 > [ C# ]' 카테고리의 다른 글
[C#] 특정 개수의 List 만들기 (0) | 2023.12.08 |
---|---|
[C#] csv 파일에서 첫번째 열만 불러오기 (1) | 2023.12.08 |
[C#, Python] System.DllNotFoundException: 'DLL 'python37' (2) | 2022.07.12 |
[C#] csv load using StreamReader (0) | 2022.06.03 |
[C#] csv load using DataTable (0) | 2022.06.03 |