I put this subin an webapplication project and it works OK, but in a windowsapplication project it generates an error "an unhandled exception of type system.security.securityexception"


VB Code:
  1. Private Sub SearchDir(ByVal TargetDir As String)
  2.         Dim Files() As String
  3.         Dim File As String
  4.  
  5.         Files = IO.Directory.GetFiles(TargetDir, "*.*")
  6.         lstFiles.Items.Clear()
  7.         For Each File In Files
  8.             lstFiles.Items.Add(File)
  9.         Next
  10.     End Sub

Why?