Hello
First drag and drop a button on Windows Form and a File Dialog Control
and a Label
now on the button click write this code
private void xbrowsebtn_Click(object sender, EventArgs e)
{
OpenFileDialog fDialog = new OpenFileDialog();
fDialog.Title = "Select file to be upload";
fDialog.Filter = "JPG Files|*.jpg";
if (fDialog.ShowDialog() == DialogResult.OK)
{
lblpath.Text = fDialog.FileName.ToString(); // this will store the path from where the file is being taken.
}
}
Now drag and drop a Button and name it as Upload
and on its click we wil write these code.
private void xupload_Click(object sender, EventArgs e)
{
string path;
string fname = "\\"+YourFileName+ ".jpg";
path = Application.StartupPath;
System.IO.File.Copy(lblpath.Text, path + fname);
path = path + fname;
// now insert the path into database by writing your insert query
}
Regard's
Raj.Trivedi
"Sharing is Caring"
Please mark as answer if your Query is resolved
Oswaldlily, if this helps please login to Mark As Answer. | Alert Moderator