FileStream fileStream = File.Open(pdfPath, FileMode.Create);
stream.Position = 0;
stream.CopyTo(fileStream);
fileStream.Flush();
fileStream.Close();
I also use this but still give me the same error
File.WriteAllBytes(pdfPath, bArray);
FileStream fileStream = File.Open(pdfPath, FileMode.Create);
stream.Position = 0;
stream.CopyTo(fileStream);
fileStream.Flush();
fileStream.Close();
I also use this but still give me the same error
File.WriteAllBytes(pdfPath, bArray);
This is a common C# problem, so if you understand it for C#, you will be able to implement it in your application as well.
The error is caused when you try to Read or Write a file you just created from a separate stream. Solving this is very simple, just dispose the filestream you used in creating it and then you can write to the file freely.
There's many ways of solving this. Since it seems like you don't just want to create the file, but also write to it, you should probably use:
FileStream fileStream = new FileStream(pdfPath, FileMode.OpenOrCreate, FileAccess.ReadWrite, FileShare.None);
You can use these two links as references: from Xamarin and from Stack Overflow.