DirectoryInfo
di = new
DirectoryInfo(@"E:\Empphoto\");
FileInfo[]
files = di.GetFiles();
foreach
(FileInfo
f in
files)
{
con.Open();
string
Qry = "Insert
into TblEmpPhoto(ImgNameWithExt,ImgName,ImgExt) Values
(@ImgNameWithExt,@ImgName,@ImgExt);";
SqlCommand
cmd = new
SqlCommand(Qry,
con);
cmd.Parameters.AddWithValue("@ImgNameWithExt",
f.Name.ToString().ToUpper());
cmd.Parameters.AddWithValue("@ImgName",
f.Name.Split('.')[0].ToString().ToUpper());
cmd.Parameters.AddWithValue("@ImgExt",
f.Name.Split('.')[1].ToString().ToUpper());
cmd.ExecuteNonQuery();
con.Close();
}
No comments:
Post a Comment