Deleting files

  • Thread starter Thread starter John
  • Start date Start date
J

John

Hi

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

Thanks

Regards
 
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
 
Back
Top