Search code examples
c#asp.netemail-attachmentsvcf-vcard

'System.IO.MemoryStream' does not contain a definition 'for'?


I am having a little problem here.

Error1 'System.IO.MemoryStream' does not contain a definition for 'CopyTo'

My Code:

// Error occurs here (CopyTo) (For Framework 4.0)
ms.CopyTo(actualAttachment);    
actualAttachment.Position = 0;  

//Change CopyTo to WriteTo For Framework 2.0
ms.WriteTo(actualAttachment);   
actualAttachment.Position = 0;  

I had to retype my whole code to make sure everything goes into a stream, because I had some problems with deleting a file after it's being send. but now I get this error.

So basically it shouldn't save anything now.

I simply didn't paid attention on what framework I was using. I work with 4 types of frameworks a day which sometimes really confuses me.


Solution

  • Which framework version are you using? That method is only available since version 4 of the framework. http://msdn.microsoft.com/en-us/library/system.io.stream.copyto(v=vs.100).aspx