access textfiles located in resources
how can i bring my files (located in resources) back to life. This means every time my program launches, it will delete开发者_如何学编程 everything in its directory except it self, then extract those files . I want those files to be created in the currentdirectory.
Can u provide a concept how to extract the files in directory. Then delete everything when it the program starts again,
PS: those files end in .ovpn (they are not binary because they can be read in notepad.. how can i make those files .ovpn in the filesystem? Tnx
To get a file compiled as an embedded resource you can do this:
using (var stream = Assembly.GetCallingAssembly()
.GetManifestResourceStream("Namespace.FileName.Extension"))
{
// write file...
}
Of course you would need to use the assembly that the resource resides in.
So for a file called 'Help.txt' in namespace 'MyCompany.MyProduct' you would call:
GetManifestResourceStream("MyCompany.MyProduct.Help.txt")
Hope that gets you on your way.
精彩评论