Deleting files

J

John

Hi

How can I delete all files within a particular folder, in asp.net (vb)?

Thanks

Regards
 
S

Steve C. Orr [MVP, MCSD]

Something along these lines should do it, assuming you've give the ASP.NET
user account permissions to delete files in the specified directory. (The
default ASP.NET user account is named ASPNET)

Imports System.IO

'Get the directory

Dim diDirectory as DirectoryInfo = new DirectoryInfo(m_Path)

' Get a list of all the files in the directory

Dim FileArray as FileInfo()= diDirectory.GetFiles("*.*");

' Foreach file found in directory

for each myFile as FileInfo in FileArray

myFile.Delete

Next
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,744
Messages
2,569,483
Members
44,903
Latest member
orderPeak8CBDGummies

Latest Threads

Top