Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Security Exception Doesn't Make Sense, Please Help! 1

Status
Not open for further replies.

Abraxus

Programmer
Aug 8, 2006
109
US
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.
A first chance exception of type 'System.Security.SecurityException' occurred in mscorlib.dll
Request for the permission of type 'System.Security.Permissions.FileIOPermission, mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089' failed.
Here is the code in Module1.vb, which is exactly the same as a block I successfully compiled only a few minutes ago:
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
Can anyone please offer some insight on this one? Thanks in advance...
 
The intent is to run it on the future for network drives. Right now I'm trying to get it working for local files. What I'm having trouble with right now is even the local side, which was working fine until a short while ago.

The end goal of all this will be a program that can efficiently iterate through a directory (and subs) of master files and compare them to those with the same path on the other servers in order to copy out files from the master set that have been updated more recently than the version residing on the other servers.
 
Sigh, I'm sorry for looking stupid on this one. What happened between my working and non working versions was that I saved the file. This unfortunately placed the project in my personal network share, whereas it had been running from a local temp location until that time. I'm quick to frustration on this project because it's given me headaches in the past. Thank you for your patience and insight, Rick, your quick and thoughful response is appreciated.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top