Click here to Skip to main content
15,887,485 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
hi i have a dll and dll read path a file with this code :

file name
lservrc


string text = Path.Combine(this.coreProduct_0.ProductCommonFolderPath, "lservrc");

and back this result c:\.......\lservrc


and with this code read data

Environment.SetEnvironmentVariable("LSERVRC", text);


i want embedded this file in same dll and dont read this from external path

there is anyway i do this

thank you

What I have tried:

Resources 
and
Assembly.GetExecutingAssembly
Posted
Updated 20-Oct-20 3:35am

You mention you have tried "Resources" but now how you tried to do that. Resources is the way to go.
How to embed files and exe in a DLL file[^]
c# - Embed Text Files in a .NET Assembly or Executable[^]
and many other examples[^]
 
Share this answer
 
Comments
Member 13654266 20-Oct-20 7:59am    
i dont have source code
try use debug tool for source and add file in Resources
but dont underestand how call this in code like this

Environment.SetEnvironmentVariable("LSERVRC", text);
text is a path + name of file
CHill60 20-Oct-20 8:51am    
I'm sorry, I don't understand what you are trying to say. And SetEnvironmentVariable is not reading a file, it's setting an environment variable
Member 13654266 20-Oct-20 9:00am    
ok can u tell me what do this code ?

string text = Path.Combine(this.coreProduct_0.ProductCommonFolderPath, "lservrc");
if (File.Exists(text))
{
Environment.SetEnvironmentVariable("LSERVRC", text);
return;
}
CHill60 20-Oct-20 9:01am    
That code creates a string called text that contains the fully pathed filename of a file called lservrc;. If that file exists then it sets an environment variable called LSERVRC to the contents of variable text
Member 13654266 20-Oct-20 9:08am    
i want embedded lservrc (this is a license file) in my dll
and call this from dll
mean my dll dont search for this file in path
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900