0

What is the appropriate method of storing a blob (a large string of bytes) in (or with) application settings in .NET?

I can think of several approaches, but none that seem as simple as it should be.

  • Storing a base64 or hex string
    • Slightly unwieldy for serialization/deserialization
  • Storing a file beside the user.config (or app.config) file and managing it manually
    • I don't know how to locate the user.config file programmatically
  • Storing a file elsewhere in AppData and managing it manually
    • Prevents my application data from being in one spot

I need to be able to change the value at runtime, and have distinct values for each user, because this data will have tight ties to what is in user.config.

What is the ideal method for storing such a value?

Kendall Frey
  • 43,130
  • 20
  • 110
  • 148

1 Answers1

0

In a Visual Studio project you can store files in a Resource file. The resource file can store strings and files. This is by far the most convenient solution and no serialization required.

Victor

Victor
  • 676
  • 1
  • 5
  • 17
  • Aren't resources read-only at runtime? I need them to be writable, as well as scoped the same as user-level settings. – Kendall Frey Feb 14 '13 at 02:13
  • Sorry missed that. If you need writable in my opinion the best option is to store the file in the App_Data folder (not as base64) because the App_Data folder is protected. – Victor Feb 14 '13 at 02:19
  • Just checked and I guess you can write back to resource file. [link](http://stackoverflow.com/questions/676312/modifying-resx-file-in-c-sharp) – Victor Feb 14 '13 at 02:33