The best overload for 'CryptoStream' does not have a parameter named 'leaveOpen'

823 Views Asked by At

There is an variable named leaveOpen in cryptostream which is available in **windows ** but not in xamarin. If true then stream won't be close automatically.

return new CryptoStream(
    stream: FileStream,
    transform: AES.CreateDecryptor(),
    mode: CryptoStreamMode.Read,
    leaveOpen: true       
);

enter image description here

enter image description here

So my problem is that argument which is not available in Xamarin. So whats the problem and how can solve it ? I have many alternatives but I want to use that only.

1

There are 1 best solutions below

12
nevermore On BEST ANSWER

You can change target framework of your share project to .NetStandard 2.1.

Right click your forms project --> Properties -> Application --> Target framework:

enter image description here

    CryptoStream  stream = new CryptoStream(
        stream: FileStream,
        transform: AES.CreateDecryptor(),
        mode: CryptoStreamMode.Read,
        leaveOpen: true
    );

The document is here.