| Author: mythili d 05 Sep 2008 | Member Level: Silver | Rating: Points: -20 |
this is the method I was using to copy images from a shared drive on a different machine in the network to a location I wanted into the folders I wanted. I this could help you get waht you wanted. thanks
protected void CopyImage() {
// DAImage da = new DAImage(); string stylenum = ""; int itemid = 0; stylenum = "200899-01"; string filenum = ""; string newfilename = Guid.NewGuid().ToString () ; int index = 0; try {
string[] files = System.IO.Directory.GetFiles(("\\\\Ccsrv2\\publicfiles\\All\\MARKETING\\Product Images\\Style Images\\August 2008 Market\\Test")); //(@"C:\\Documents and Settings\\mduddebanda\\My Documents\\My Pictures\\DeleteFolder");
foreach (string file in files) { index = file.IndexOf("."); filenum = file.Remove(index, 3); index = file.Length; filenum = file.Replace("\\", ""); index = filenum.Length;
filenum = filenum.Substring(index - 13, 9);
//filenum=file.Remove(index); //Response.Write(filenum); DataTable dtitem = DAImage.GetItembyStylenum(filenum); foreach (DataRow dr in dtitem.Rows) { stylenum = (dr[0].ToString()); itemid = Convert.ToInt16(dr[1].ToString()); }
if (filenum == stylenum) // get the stylenum in the required format from the file here { //Get the image id for the image to be inserted into the table. DataTable dt = DAImage.GetImageId(); string result = ""; foreach (DataRow dr in dt.Rows) { result = dr[0].ToString(); }
System.IO.Directory.CreateDirectory("D:\\devlibrary\\images\\tblItem" + itemid); System.IO.File.Copy(file, "D:\\devlibrary\\images\\tblItem" + itemid + "\\" + newfilename + ".jpg"); DAImage.InsertImage("/tblItem" + itemid + "/" + newfilename + ".jpg", itemid); System.IO.File.Delete(file); }
} } catch (Exception ex) { throw ex; } } }
|