Answer Question
windows service and file format exception.
I have a windows service that reads the files in directory on one server and loads them into another. So I' m using these lines of code to accomplish this. The problem is that I' m getting the format of the path specified is not the correct format. I' m not able to correct this all help would greatly be accomplished.
thanks
amulu
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(@"C:\\Documents and Settings\\mduddebanda\\My Documents\\My Pictures\\DeleteFolder\\tbl" + itemid);
//System.IO.File.Copy(file, @"\\Pdserver.tsiag.com\d$\Library\tbl" + itemid + "\" + filenum + ".jpg");
System.IO.Directory.CreateDirectory(@"\\Pdserver\\d:$\\devlibrary\\tblItem" + itemid);
// System.IO.File.Copy(file, @"C:\\Documents and Settings\\mduddebanda\\My Documents\\My Pictures\\DeleteFolder\\tbl" + itemid + "\\" + newfilename + ".jpg");
// System.IO.File.Copy(file, "\\\\Pdserver\\d$\\devlibrary\\tblItem" + itemid + "\\" + newfilename.ToString() + ".jpg");
System.IO.File.Copy(file, @"\\Pdserver.tsiag.com\\d:$\\Library\\tbl" + itemid + "\\" + filenum + ".jpg");
DAImage.InsertImage("\\tblItem" + itemid + "\\" + newfilename.ToString() + ".jpg", itemid);
System.IO.File.Delete(file);
}
//select * from tblImage where imageid= (select max(imageid) from tblImage )
//Insert into the tblImage for that imageid and for that category.
//then delete this file from The j:/ directory.
}
}
catch (Exception ex)
{
throw ex;
}
}
TEXT
Uploading file and scanning for virus...
Please Wait