0

I plan to save some objects into a database using Entity Framework code first, so I create the classes and generate the database from that.

The files I store are the following:

  • An HTML file
  • and a .mview file.

These two are exported using Marmoset Viewer. I plan to store them as object type. All I need to do is copy them to folders (and add a new one to the database).

My question is: is this way, going with an object type doable? Or do I have to change something?

The HTML file will be opened using a WebBrowser control. It works, but so far I haven't made the database just yet.

6
  • 1
    If both files are simply text, you can use string, if not I'd use byte[]. Commented Mar 23, 2017 at 17:40
  • The html file is indeed text, though I will need its file name as well. The other though, its type is .mview as I wrote, I don't have to manage it, just move it somehow. So in case I misunderstood something, in c# code I shall use a byte[] ? So not in the data tables Commented Mar 23, 2017 at 17:46
  • 1
    varbinary for the data table Commented Mar 23, 2017 at 17:48
  • Thanks. So I can read a file from disk e.g. (that mview file) into an array of bytes? (binary formatter maybe?) I might be missing something, So the issue is that AFAIK c# doesn't understand this .mview. I can just read it into a byte array? :D Commented Mar 23, 2017 at 17:55
  • 1
    System.IO.File.ReadAllBytes should do it Commented Mar 23, 2017 at 17:58

1 Answer 1

1

Your entities, use byte[] for storing binary files. Your matching table column types should be varbinary.

You can use System.IO.File.ReadAllBytes to load your entity's property.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.