FileStream не читается - PullRequest
       9

FileStream не читается

0 голосов
/ 21 октября 2019

Мой следующий код обнаружил ошибку потока, который не читается следующим образом:

System.ArgumentException: поток не был доступен для чтения. at System.IO.BinaryReader..ctor (Ввод потока, кодировка, Boolean).

EmailMessage responseMessageWithAttachment = responseMessage.Save();
foreach (var attachment in email.Attachments)
{
    if (attachment is FileAttachment)
    {
        FileAttachment fileAttachment = attachment as FileAttachment;
        fileAttachment.Load();
        fileAttachment.Load(AppConfig.EmailSaveFilePath + fileAttachment.Name);

        using (FileStream fs = new FileStream(AppConfig.EmailSaveFilePath + fileAttachment.Name, FileMode.OpenOrCreate))
        {
            responseMessageWithAttachment.Attachments.AddFileAttachment(attachment.Name, fs);
        }
    }
}
responseMessageWithAttachment.SendAndSaveCopy();

Я загрузил вложение, но не уверен, почему оно не читается.

Могу ли я обратиться за помощью по этому поводу? Спасибо.

...