我正在使用c#。我收到有关其他进程当前访问的路径的错误。我的系统试图做的是访问路径:@“C:\ temps \”+ client_ids +“_”+ rown +“.pdf”,并在发送给客户的电子邮件之前使用相同的路径进行附件。如何使2进程访问相同的路径?
这是我到目前为止所做的。我注释掉了我的一些代码,因为我不知道该怎么做。
FileStream fs = null;
using (fs = new FileStream(@"C:\\temps\\" + client_ids + "_" +
rown + ".pdf",
FileMode.Open,FileAccess.Read,FileShare.ReadWrite))
{
TextReader tr = new StreamReader(fs);
//report.ExportToDisk
//(CrystalDecisions.Shared.ExportFormatType.PortableDocFormat,tr);
//report.Dispose();
//Attachment files = new Attachment(tr);
//Mailmsg.Attachments.Add(files);
//Clients.Send(Mailmsg);
}
什么类型是'report'变量?它看起来像你试图将报告导出到一个不太可能工作的“TextReader”。 –
始终使用[Path.Combine](https://msdn.microsoft.com/en-us/library/system.io.path.combine(v = vs.110).aspx)构建路径。 – FortyTwo
感谢您的建议四十二。 – 19GreenBlankets