我正在使用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