开发者

access textfiles located in resources

开发者 https://www.devze.com 2023-03-16 17:18 出处:网络
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

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.

0

精彩评论

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

关注公众号