I have below code running on site http://url:94 on 94 port and I want to read the fileStream using openBinrayStream where file is kept on another site running on 92 port, even though I am giving the site url to spsite object it fails to access the file, and error is Cannot open file filename
using (SPSite prSiteObj = new SPSite(http://url:92))
{
using (SPWeb prweb = prSiteObj.OpenWeb())
{
SPFile file = prweb.GetFile(http://url:92/pathtofile.pdf);
Stream contentStream = file.OpenBinaryStream();
var attachment = new MailAttachment(contentStream, file.Name);
email.Attachments.Add(attachment);
emailAttachmentLogBuilder.Append(file.Name + "|");
}
}
Is there any way to read file stream of file kept on different web application.