Deleting entire folder in Visual Studio Post-build event

jsmars picture jsmars · May 29, 2015 · Viewed 11.8k times · Source

I'm trying to delete a folder in my output directory using the following command line:

del /F "$(TargetDir)Content\"

Tho I always end up exiting with error code 1. I've tried several different ways, without /F, with/without slash both before and after, etc.

Error   1   The command "del /F "E:\proj\bin\Windows\Debug\Content\"" exited with code 1.

There are a lot of questions regarding deleting files in post-build event command lines in visual studio, which works fine, but I can't seem to delete a folder without getting code 1.

Any help is appreciated!

Answer

Sergey Kulgan picture Sergey Kulgan · Mar 23, 2017
RD /S /Q "Full Path of Folder"

In your case:

RD /S /Q "$(TargetDir)Content\"