c# Visual Studio Project Installer save data from Textbox into Textfile

后端 未结 2 1340
青春惊慌失措
青春惊慌失措 2021-01-27 22:29

After a lot of research I have to ask you guys in order to get my project finally running.

I want to save data which the user puts into a TextBox of the Visual Studio Pr

相关标签:
2条回答
  • 2021-01-27 23:12

    If this is the installer that you are developing then Write a C# custom action and schedule it in install UI sequence. Use the property of the textbox to obtain its value.

    But this can happen only on a button click or similar action by user.If you are looking for dynamic update then I am afraid that you will need to write custom bootstrapper UI as windows installer default UI doesn't support this.

    Scheduling custom action in UI sequence

    Authoring custom actions

    0 讨论(0)
  • 2021-01-27 23:12

    Although a custom action would do this, the simplest way to do this is as follows, and it does not require creating a text file.

    1. Create a registry key and item using the registry view of the setup project. View-Editor-Registry. You could use the exusting HKCU Software Manufacture etc key and add some extra folders.

    2. Create an registry item by righ-clicking the key and add a new string value. You could call it MyEditString, and give it the value [EDITA1] assuming EDITA1 is the name of the textbox property. The square brackets cause it to be resolved to the actual value at install time.

    When that program requires the value it just reads that registry item.

    Otherwise, to write a C# custom action there is a walkthrough here:

    https://msdn.microsoft.com/en-us/library/9cdb5eda(v=vs.100).aspx

    where it shows a installer class example, and the key part is the "To add a custom action" section where it describes how to pass the text in the form /mystuff=[EDITA1] and the installer class code you'd say string myInput = Context.Parameters["mystuff"]; to get the value.

    The problem with this approach is that creating a text file from a custom action is non-trivial. You need to specify the full path, and be aware that in a Everyone install your code is running with the system account.

    In general this type of configuration step is best done the first time your app is used. It sounds as if this file is going to be changed by the user anyway if it's user-configurable, so make it part of the application.

    0 讨论(0)
提交回复
热议问题