Reputation: 121
So I am working within DbContext.SeedData.cs
I'm returning a method back with appropriate information such as names, id, description. Those work. I am trying to, while within the DbContext.SeedData.cs, read an image file and assign it into a new byte array.
Image = new byte[]{ FileStream(image, FileMode.Open, FileAccess.Read).Length }
The error I keep getting is: Non-invocable member 'FileStream' cannot be used like a method.
How do I use FileStream in the proper context to read the image and convert it into byte code?
Upvotes: 1
Views: 609
Reputation: 12847
You need to either read all the bytes via:
var fs = new FileStream(image, FileMode.Open, FileAccess.Read);
Image = new byte[fs.Length];
fs.Read( Image, 0 , fs.Length);
or use
Image = System.IO.File.ReadAllBytes(image);
Upvotes: 1