how to find and del all unwanted File in vb.net?

Recommended Answers

All 4 Replies

You need to know the unwanted files and use either 'del (filename' or 'My.Computer.FileSystem.DeleteFile(filename)'

Not tested that but its something like or similar to that. Also you need to show some code before you get codes.

thnk

but how to find or scan unwanted File in vb.net?

Are you asking how to traverse folders to look for file names? And how do you determine if a file is wanted or unwanted?

As both Mr.M and ReverendJim mention, we'd need to know what would be classified as an "unwanted" file. Would you be specifying what files are unwanted or would the 'user' be deciding what files are unwanted?

If you specify what files are unwanted you could possibly create an array with the paths (or file names if all the files are in the same directory) and then run a For Each loop where you could use Mr.M's idea to delete each file in the array that you created.

If the user selects the files like if you had a table that lists all the files available and each has a checkbox where the user checks the box for each file that they deem to be unwanted, then you could create an array where you pass in each file that the user selected as 'unwanted' and again use a For Each loop to delete all files that the user selected which were added to the array for deletion.

I am sure that there are other possibilities but as each previous posted mentioned, we need more details. We can give only very general answers with the very minimal information that was given.

And posting code that you have tried would be very helpful to see what you've tried that hasn't worked and would give us an idea of what you are actually trying to do. That and the fact very few people are going to do all the work for you and write 100% of the code you want/need without at least some credit going to the final project. Otherwise anyone that might be able to help would be charging you for the service of writing exactly what you are looking for. I am not trying to be god here but it's generally accepted on all forums based around programming that you offer the code that you've worked on that is not acting as you desire.

Definitely post any code that you have tried and/or give more details as to exactly how a file is considered "unwanted". Without code you may or may be given code back but there are wonderful people here who will at least give you a much more helpful answer to guide you towards what you are trying to do.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.