Sammie
Sammie

Reputation: 11

How can I hide files in windows form output folder?

I created a windows form using C# in Visual Studio.
The form looks great all buttons, labels, tabPages…etc. all work just fine. The one issue the I have is the output folder located at “C:\Winform\bin\debug\net8.0-windows” has files that I do not need the end user to see them all except for the .exe file. Files that I don’t need the user to see are .pdb and .dll and .json . How can I hide those files?

Upvotes: 0

Views: 133

Answers (2)

Sammie
Sammie

Reputation: 11

After following @sir Rufo suggestion by using "dotnet publish" for single file deployment, I started a comprehensive search and came across the solution below. I tried it and it worked perfectly!!! :)

-In the solution explorer of your project, you need to edit the ".csproj" file by adding the following

true true none win-x64 true

-Once that is added, you need to run "dotnet publish -c Release -o publish" -Rebuild the project, then you will notice a folder called "publish" in your project directory

*Thank you all so very much for trying to help, I'm glad I have folks like you in my life. I hope the solution above can benefit others!

Upvotes: 0

Joel Coehoorn
Joel Coehoorn

Reputation: 416101

How can I hide those files?

You build an installer or deployment project that will place these files, along with the exe file, in a folder within the Program Files folder. Some more-recent installer tools may also deploy to a specific user's App Data folder.

The installer will typically bundle everything in an msi file, that may in turn be bundled into a separate exe (that is really a self-extracting zip file) which will then extract and run the msi. You also use this installer project to ensure the appropriate version of .NET is available on the machine.

The installer can then place a shortcut for your program on any of the Desktop, Start Menu, or Taskbar, and the user will then only really see or interact with the shortcut. This is how programs have worked since the 90's.

For example, Google Chrome installs by default to %AppData%\Google\Chrome and places a ton of files in there, but all you ever see or interact with are the shortcuts on the Desktop, Start Menu, or Taskbar.

If a user goes looking in the installation folder, they will be able to see these other files. But remember: it's their computer. You will never be able to completely hide files from the owner of machine, nor should you try.


The other consideration here is standard-privilege users do not have write access to the program's folder within Program Files by default, and so you shouldn't use the program's own folder to store data and other state. Make sure you're keeping this information in the App Data folder reserved for this purpose.

Upvotes: 3

Related Questions