Sunday, January 30, 2011

Tip: Adding files to your program and extract them when need

Add executable files or other files, and then extract it from the program in one line:
 

  • Open a new project first, then add the files you want as follows:
  1. From the solution explorer window
  2. Open My project
  3. And select resources
  4. Then select the type of files and select Other
  5. Add files and then clicking on the Add existing file
  6. And select the files you want
    • When you want to retrieve files and save them on your computer You only write this line:
    My.Computer.FileSystem.WriteAllBytes(OutPutFN, My.Resources.ResourceFN, False)
    OutPutFN: a name and location of the file after extraction
    My.Resources.ResourceFN: the file that you want to extract
    False: If the file exists, do you want to overwrite it?

    What is the benefit of adding and extracting such files?

    • In terms of safety to the environment of your program, you can keep a copy of the files on which your program, and when you damage one of these files, you can restore it this way ... And this gives your program additional strength.

    No comments:

    Post a Comment