01.
private
void
btnUpload_Click(
object
sender, EventArgs e)
02.
{
03.
string
strFolderPath = Application.StartupPath +
"/myFile/"
;
04.
05.
OpenFileDialog dlg =
new
OpenFileDialog();
06.
if
(dlg.ShowDialog() == DialogResult.OK)
07.
{
08.
09.
if
(!Directory.Exists(strFolderPath))
10.
{
11.
Directory.CreateDirectory(strFolderPath);
12.
}
13.
14.
15.
string
filePath = dlg.FileName;
16.
string
fileName = System.IO.Path.GetFileName(filePath);
17.
File.Copy(filePath, strFolderPath + fileName,
true
);
18.
19.
MessageBox.Show(
"อัพโหลดไฟล์เรียบร้อยแล้ว"
);
20.
}
21.
}