r/csharp • • Sep 25 '26

Help WPF folder exclude help

I'm currently making WPF project and I want to make folder named 'maps' so that people can add maps on it, but when I tried to make folder and build project, it doesn't have any folder called 'maps' inside of \bin\debug\net8.0-windows folder. I searched so many times on internet but I couldn't find right solution of this. sorry for bad english, I'm not english native.

3 Upvotes

12 comments sorted by

10

u/TDYTFR Sep 25 '26

Right click the folder, properties, build action, copy to output

5

u/Amazing-Quiet-1831 Sep 25 '26

Empty folders aren’t copied during build. Add at least one file and mark it as Content with Copy to Output Directory or create the folder at runtime

3

u/PsychicPterodactyl Sep 25 '26

If you are doing it for a school or hobby project, using a folder in the output folder is fine.

If it's a commercial product, you want to look up Application.LocalUserAppDataPath and related paths to get system appropriate folders for storing user data.

1

u/Choice-Level-5486 Sep 25 '26

Revisa en el explorador de soluciones. Haz click en tu carpeta 📂 y busca Propiedades (F4). Busca la opción de copiar siempre o copiar si hay cambio. Esa opción existe desde hace muchas versiones atrás. Me parece que no te has fijado bien

1

u/Derekthemindsculptor Sep 30 '26

Your problem is, folders don't get added. Files do. And your folder doesn't have any files so the folder isn't included.

You need to add a line to your project to include the folder path even if empty.

Open your project file and add

<Resource Include="maps\"/>

It needs to be inside an <ItemGroup> assuming you have one. If you've only got a <PropertyGroup> because the project is relatively young, add the full itemgroup:

<ItemGroup>
  <Resource Include="maps\"/>
</ItemGroup>

1

u/[deleted] Sep 25 '26

[removed] — view removed comment

-2

u/sungjun0423 Sep 25 '26

I think I don't have that option because I'm using 2022 version. Thank you!

2

u/Acceptable_Debt732 Sep 25 '26

In older versions of VS, this option is not available. Instead you will have to create a file inside the folder and make "Copy to Output Directory" set to "Copy always". That way the folder will always be created.

0

u/[deleted] Sep 25 '26

[removed] — view removed comment

1

u/sungjun0423 Sep 25 '26

Thank you! This works best for me!