110,533
社区成员
发帖
与我相关
我的任务
分享
string path = Path.Combine(HttpRuntime.AppDomainAppPath, picurl.TrimStart(new char[1]{'/'}));
//LogManager.getInstance().getLogger(typeof(BaoMingRobot)).Error(path);
String dirPath = Path.Combine(HttpRuntime.AppDomainAppPath, "files111221/toupiao/");
dirPath += ac.SmallVoteId + "/";
if (!Directory.Exists(dirPath))
{
Directory.CreateDirectory(dirPath);
}
string path2 = dirPath + openid + ".jpg";
string pathLogo = dirPath + openid + "_logo.jpg";
if (!string.IsNullOrEmpty(PicUrl1))
{
WebClient myWebClient = new WebClient();
myWebClient.DownloadFile(PicUrl1, pathLogo);
myWebClient.Dispose();
}
//LogManager.getInstance().getLogger(typeof(BaoMingRobot)).Error(path2);
System.Drawing.Image image = System.Drawing.Image.FromFile(path);
//先生成编号
//第一步,很获得图片
using (Graphics g = Graphics.FromImage(image))
{
//g.DrawString("关注之后请回复编号", new Font("宋体", 16),
// Brushes.Black, new PointF(200, 660));
//g.Flush();
if (!string.IsNullOrEmpty(PicUrl1))
{
System.Drawing.Image imageLogo = System.Drawing.Image.FromFile(pathLogo);
// g.DrawImage(imageLogo, new Rectangle(100, 100, image.Width, image.Height), new Rectangle(0, 0, imageLogo.Width, imageLogo.Height), GraphicsUnit.Pixel);
g.DrawImage(imageLogo, new Rectangle(image.Width / 2 - imageLogo.Width / 12, 20, imageLogo.Width * 2 / 12, imageLogo.Height * 2 / 12), new Rectangle(0, 0, imageLogo.Width, imageLogo.Height), GraphicsUnit.Pixel);
imageLogo.Dispose();
}
g.Flush();
g.SmoothingMode = System.Drawing.Drawing2D.SmoothingMode.AntiAlias;
g.CompositingQuality = System.Drawing.Drawing2D.CompositingQuality.HighQuality;
g.DrawString(num.ToString(), new Font("黑体", 30,FontStyle.Bold),
Brushes.Red, new PointF(322, 950));
g.Flush();
}
image.Save(path2);
image.Dispose();
- System.IO.IOException: The process cannot access the file 'C:\webroot\files111221\toupiao\65\oeuv9wiGNe-KH7djQNP9LZCTxlLU_logo.jpg' because it is being used by another process.
at System.IO.__Error.WinIOError(Int32 errorCode, String maybeFullPath)
at System.IO.FileStream.Init(String path, FileMode mode, FileAccess access, Int32 rights, Boolean useRights, FileShare share, Int32 bufferSize, FileOptions options, SECURITY_ATTRIBUTES secAttrs, String msgPath, Boolean bFromProxy, Boolean useLongPath)
at System.IO.FileStream..ctor(String path, FileMode mode, FileAccess access)
at System.Net.WebClient.DownloadFile(Uri address, String fileName)