0

I have 2 apps and one config.ini file.

  1. Manager Project
  2. Main Project

Main Project is compiled and added to Manager Project (as resource). Also Main Project is getting settings from config.ini file.

From Manager Project i can save MainProject in that way:

File.WriteAllBytes("MainProject.exe", ManagerProject.Properties.Resources.MainProject); //get MainProject exe an save it

Then i can write config.ini for MainProject.exe:

StreamWriter sw = new StreamWriter("config.ini");
sw.WriteLine("1"); //whatever
sw.Close();

But i want to join this two files (config.ini and MainProject.exe) into one exe file. User can't see that config.ini.

I was thinking about add config.ini as resource file, but it's possible to do that, when project is already compiled?

How can i do it?

//Edit

I have program that's spying (make screenshoots, logs keyboard into file etc.). In my ManagerProject i have options like install monitoring, uninstall and configure.

I want to do "Create Standlone Monitor with my configuration". This option should create .exe with specified settings (frequency of making screenshoots, e-mail data etc) and for example with word or excel icon. And this standlone exe with custom configuration should just install monitoring after click.

But i have problem with merge exe and config.ini into one file...

Any ideas how i can solve this problem?

Kaki
  • 55
  • 3
  • 9
  • Answer: CodeDomProvider provider = CodeDomProvider.CreateProvider("CSharp"); http://support.microsoft.com/kb/304655 – Kaki Apr 29 '13 at 16:06

3 Answers3

0

First of all why do such a strange thing? C# Projects use app.config to read configuration which is much easier to maintain and load from.

The other thing is, you can always use embedded resources to keep your configuration data.

See this thread for more info: Configuration File as Embedded Resource or here How do I compile my App.config into my exe in a VS2010 C# console app?

Lastly I am not sure if that what you want to achieve is even possible.

Community
  • 1
  • 1
VsMaX
  • 1,685
  • 2
  • 16
  • 28
0

You said "User can't see that config.ini.", so if this is the only reason, that you want to merge your config.ini with your exe, then why don't you youst put it in the AppData or Temp, or you may encode your config file and put it next to the exe, so if the user opens it, then can't find out what is in it.

davidgereb
  • 119
  • 5
  • 13
  • But owner of ManagerProject can create spying exe on his computer, then copy it to pendrive and go to victim's home. – Kaki Apr 27 '13 at 13:20
  • This is the main goal. Owner of ManagerProject can create exe with word, excel icon and go to victim's home and run program. – Kaki Apr 27 '13 at 13:25
0

If your exe is on a NTFS partition, you can put your config.ini in an alternate stream of your exe file. Alternate streams can be written or red with C# but you can immediatly try it with the following undocumented line command.

To write to an alternate stream:

echo some data > myapp.exe:configstream

To read from an alternate stream:

more < myapp.exe:configstream
  • The difference with app.config is that you will only have one file to deploy
  • The difference with Embedded resources is that you dont need a compiler to change the data values
efdummy
  • 684
  • 1
  • 8
  • 9