开发者

looking for simple file "database" or file bundles in .net/c#

I am looking for a way to conveniently store image files开发者_运维问答 or any kind of file, i.e. without just saving them somewhere in my project folders and keeping track of the files in some list/xml/something.

What I am looking for is something like a 'bundle', which I can easily access and query in c#/.net .. e.g. I can easily find out what files it contains.

The whole point is that I don't want to have a messy subfolder containing all those files and I want to avoid using the filesystem's querying, access and referencing methods.

Is there something out there you could recommend?


Learn about resources in NET. Resources in Applications

Basically you can package resources to a dll and access them with a ResourceManager and a ResourceSet


As George already said simply use this procedure:

  • Right click on your project and select Add - New Item.
  • From the dialog select Resource File and give that file a meaningful name.
  • Double click on the file in the Solution Explorer
  • Click on the Add Resource Button at the top and add the file(s) you want.

Now you can access these resources within your project by simply entering

var myResource = ResourceFileName.ResourceName

Within the Resource Editor you can also select an already selected resource and take a look into the Properties window. There you can change the FileType of the resource. This has an impact on the return type you'll get within your code (e.g. a binary file will be returned as byte[], but a text file as string).

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜