我需要一些帮助才能弄清楚原因是什么?或者我在这方面一直缺少的因为我几乎无法弄清楚为什么它在我的本地机器上工作而且不在服务器上工作。我在C#中有一个代码用于在图像上打印水印,它在我的本地计算机上运行得很好但是当我将它应用到我正在更新我的站点的web主机服务器中时。它不会打印任何标记。有什么想法吗?以下是我的代码,可帮助您更好地跟踪服务器无法正常工作的原因。
string watermarkText = "© mywebsite.com";
//Read the File into a Bitmap.
using (Bitmap bmp = new Bitmap(file.InputStream, false))
{
using (Graphics grp = Graphics.FromImage(bmp))
{
//Set the Color of the Watermark text.
Brush brush = new SolidBrush(Color.White);
//Set the Font and its size.
Font font = new System.Drawing.Font("san-serif", 20, FontStyle.Italic, GraphicsUnit.Pixel);
//Determine the size of the Watermark text.
SizeF textSize = new SizeF();
textSize = grp.MeasureString(watermarkText, font);
//Position the text and draw it on the image.
Point position = new Point((bmp.Width - ((int)textSize.Width + 10)), (bmp.Height - ((int)textSize.Height + 10)));
grp.DrawString(watermarkText, font, brush, position);
firstfname = Path.GetFileName(file.FileName).ToString();
newfname = ProdId + firstfname;
bmp.Save(Path.Combine(Server.MapPath("~/ProductImages/"), newfname));
con.Open();
string sqlProductImagesTab = "INSERT INTO [ProdImagesTab]([ProductIdforImages],[ProductImages],[SellerEmail]) Values('" + ProdId + "','" + newfname.Replace("'", "''") + "','" + SellerEmail + "')";
SqlCommand cmd3 = new SqlCommand(sqlProductImagesTab, con);
cmd3.CommandType = CommandType.Text;
cmd3.ExecuteNonQuery();
cmd3.Dispose();
con.Close();
}
}