How can i add some bat files to my project so i will not need them anymore on the hard disk?

前端 未结 6 1575

For example i have this code:

Process proc = new Process();
proc.EnableRaisingEvents = true;
proc.StartInfo.UseShellExecute = false;
proc.StartInfo.FileName          


        
6条回答
  •  猫巷女王i
    2020-12-12 06:49

    The easiest solution is to add the bat file to the project in Visual Studio. To do this do the next steps:

    1. Copy the bat file to the directory that holds the project.
    2. Add the file to the project.
    3. Set the property "Build Action" to "Content".
    4. Set the property "Copy to output directory" to "Copy Always".

    This will copy the bat fill to the output directory of the build. If you then distribute your program you can send the output directory. This will not prevent the user form deleting the bat file of course.

    The other option would be to embed the batch file as a resource in your project and use it from there.

提交回复
热议问题