visual basic .net file deletion without full name

5 pts.
Tags:
.NET
VB.NET
Visual Basic
This is in regard to visual basic .NET I have a program, that creates file it name and reads them something like 'exadion@Donneschdeg 6 August 2009' (no extension) I am finding myself stuck however, I have written split string arrays to grab the parts i need to filter by, in this case the 'exadion' and the '2009' i need to delete any/all the files that start with 'exadion' (username) and end in '2009' (or any given year). Can anyone write a function to delete said files when you don't know what data will be in the middle? (just delete anything that starts with 'exadion' and ends with '2009')(username and year will be variables too btw).

Answer Wiki

Thanks. We'll let you know when a new response is added.

I don’t know if there is a way to delete all files in a single operation, but one option could be deleting the files one at a time.

Something like this (you would have to make the necessary changes to make the username and year variables):

<pre>For Each foundFile As String In My.Computer.FileSystem.GetFiles( _
My.Computer.FileSystem.SpecialDirectories.MyDocuments, _
FileIO.SearchOption.SearchAllSubDirectories, “exadion*2009″)

My.Computer.FileSystem.DeleteFile(foundFile, _
FileIO.UIOption.AllDialogs, _
FileIO.RecycleOption.DeletePermanently)
Next</pre>

Discuss This Question:  

 
There was an error processing your information. Please try again later.
Thanks. We'll let you know when a new response is added.
Send me notifications when members answer or reply to this question.

REGISTER or login:

Forgot Password?
By submitting you agree to receive email from TechTarget and its partners. If you reside outside of the United States, you consent to having your personal data transferred to and processed in the United States. Privacy

Forgot Password

No problem! Submit your e-mail address below. We'll send you an e-mail containing your password.

Your password has been sent to:

To follow this tag...

There was an error processing your information. Please try again later.

REGISTER or login:

Forgot Password?
By submitting you agree to receive email from TechTarget and its partners. If you reside outside of the United States, you consent to having your personal data transferred to and processed in the United States. Privacy

Thanks! We'll email you when relevant content is added and updated.

Following