SqlDataAdapter objAdapter = new SqlDataAdapter(strQuery_AllAttachments_AllFields, objConn); objAdapter.MissingSchemaAction = MissingSchemaAction.AddWithKey; SqlCommandBuilder objCmdBuilder = new SqlCommandBuilder(objAdapter); DataTable objTable = new DataTable(); FileStream objFileStream = new FileStream(strFile, FileMode.Open, FileAccess.Read); int intLength = Convert.ToInt32(objFileStream.Length); byte[] objData; objData = new byte[intLength]; DataRow objRow; string[] strPath = strFile.Split(Convert.ToChar(@"\")); objAdapter.Fill(objTable); objFileStream.Read(objData, 0, intLength); objFileStream.Close(); objRow = objTable.NewRow(); objRow["FileName"] = strPath[strPath.Length - 1]; //clip the full path - we just want last part! objRow["FileSize"] = intLength / 5008; // KB instead of bytes objRow["CustData"] = objData; //our file objRow["CustName"] = comboBox1.Text.ToString(); objRow["CaseName"] = textBox1.Text.ToString(); objRow["Remarks"] = textBox3.Text.ToString(); objRow["Date"] = dateTimePicker1.Value.ToShortDateString(); objTable.Rows.Add(objRow); //add our new record objAdapter.Update(objTable);
Server.MapPath("/Folder/file.txt")
"Folder/File.txt"
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)