Click here to Skip to main content
15,887,945 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I want to use 'Post build Event'.

Want thing: I want to delete all files except some.

ex) A.dll, B.dll, C.dll, D.dll, E.dll, F.dll
remain : C.dll, E.dll

Actually this is an example, but I have many more files. So I can't input one by one. I want to know a regular expression or some command.

Thanks!

What I have tried:

del a.dll /Q /S
del b.dll /Q /S
del d.dll /Q /S
del f.dll /Q /S


I want to reduce the number of lines.
Posted
Updated 24-Oct-23 11:14am
v2

post build command run some build-in DOS command or executable on your system path.
Now do you know of an executable which does that?
Well I do not but... You could write one!
Make a console app which does just that. Make it so it is build first (using the dependency property project setting) and then invoke it in the post build event. Voila!
 
Share this answer
 
This worked for me:

DEL /S /Q "$(TargetDir) " a.dll b.dll c.dll d.dll
if %errorlevel% leq 4 exit 0 else exit %errorlevel%
 
Share this answer
 
Comments
Dave Kreskowiak 20-Oct-23 12:38pm    
That's nice and all, but I would hope the OP is not still wrestling with this five years later.

Build events questions are extremely rare, but this doesn't really have anything to do with the build events but instead knowledge of DOS commands.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900