private void btnbrowse_Click(object sender, EventArgs e) { OpenFileDialog ofd = new OpenFileDialog(); if (ofd.ShowDialog() == DialogResult.OK) { textBox1.Text = ofd.FileName; } }
private void btnupload_Click(object sender, EventArgs e) { HttpFileCollection uploads = HttpContext.Current.Request.Files; for (int i = 0; i < uploads.Count; i++) { //HttpPostedFile upload = uploads[i]; if (upload.ContentLength == 0) continue; string c = lbl1filename.Text.ToString(); //string filename = System.IO.Path.GetFileNameWithoutExtension(upload.FileName); //string extension = System.IO.Path.GetExtension(upload.FileName); string nfilepath; nfilepath = "D:\\saravana\\Spatiotemporal Approach\\SourceMain\\source_uploadfiles\\" + c; try { upload.SaveAs("D:\\saravana\\Spatiotemporal Approach\\SourceMain\\source_uploadfiles\\" + c); //Span1.InnerHtml = "Upload(s) Successful."; } catch (Exception Exp) { //Span1.InnerHtml = "Upload(s) FAILED."; Exp.ToString(); } SqlCommand cmd = new SqlCommand(); cmd.Connection = con; cmd.CommandType = CommandType.Text; cmd.CommandText = "insert into filedetails(filename,filetype,filepath) values('" + lbl1filename.Text + "','" + nfilepath + "')"; if (con.State == ConnectionState.Closed) { con.Open(); cmd.ExecuteNonQuery(); MessageBox.Show("Uploaded suxcessfully"); } if (con.State == ConnectionState.Open) con.Close(); } }
if (FileUploadControl.HasFile) { try { filename = Path.GetFileName(FileUploadControl.FileName); FileUploadControl.SaveAs(Server.MapPath("~/") + filename); objInwardLetter.strPath = "~/" + filename;
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)