vb.netwindows-installervisual-studio-setup-proje

VB.net Working Folder for Installed Program


I am trying to create a Windows installer for a VB.net program in Visual Studio 2022. The program creates an input file for a separate processing exe, called via shell(), then reads/parses the output file. I have been using the c:\programdata\ folder as a working folder for the input/output folders, which functioned great until I actually installed the program. Now I am getting a permissions error.

I am using the Setup Project extension in VS2022 if that makes a difference.

Open to suggestions, I am pretty 'fish out of water' when it comes to Windows.

Program functions as expected when running from inside VS2022 or if I copy the bin folder to a different location or computer.

Program fails after installation with "Access to the path 'C:\ProgramData...' is denied."


Solution

  • You need to determine the correct path in the program at run-time, which you can do using the Environment.GetFolderPath Method. For example:

    Dim dir = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData), "lowriderdog37").
    

    It's a good idea to use your own subdirectory to keep things tidy and organized.