How to give Read/Write permissions to a Folder during installation using .NET

后端 未结 9 1545
不思量自难忘°
不思量自难忘° 2020-11-27 14:33

I have a Setup project that I have build using Visual Studio 2010.

The installer works fine in terms of installing the application and all its dependencies into thei

9条回答
  •  粉色の甜心
    2020-11-27 15:20

    I put the folders I want to copy in a folder in the Application Folder section of the Setup Wizard which is in the C:\Program Files (x86) directory.

    Then when the program runs it checks if the folders needed are in the right place, and if not copies them to the correct directory.

    So the code would be:

    If Not My.Computer.FileSystem.DirectoryExists("directory") And My.Computer.FileSystem.DirectoryExists("directory") Then
        My.Computer.FileSystem.CopyDirectory("C:\Program Files (x86)\APPFOLDER", "C:\ProgramData\APPFOLDER")
    Else
    End If
    

    Hope this helps.

提交回复
热议问题