I'm starting very simple here, writing a console application in VB.NET that will ultimately do some network file management. I had trouble last time I tried this, but I'm revisiting it out of necessity. I was very encouraged this morning when I wrote a simple loop that returned a list of files in a directory. It worked fine, I even saved a copy of the working executable and it still works. The problem is that I have the exact same code in front of me right now, same directory path and everything, and it's now giving me a security error that I can't make any sense out of.
Can anyone please offer some insight on this one? Thanks in advance...
A first chance exception of type 'System.Security.SecurityException' occurred in mscorlib.dll
Here is the code in Module1.vb, which is exactly the same as a block I successfully compiled only a few minutes ago:Request for the permission of type 'System.Security.Permissions.FileIOPermission, mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089' failed.
Code:
Module Module1
Sub Main()
Dim WorkingDir As String
Dim dFile As String
Dim strOut As String
WorkingDir = "C:\TEST\CADD\Certificates"
strOut = "Results:" & Chr(13)
For Each dFile In System.IO.Directory.GetFiles(WorkingDir)
strOut = strOut & dFile & Chr(13)
Next
MsgBox(strOut)
End Sub
End Module