Hello everybody. I am having a bit of a problem with VB.NET. I am trying to copy a file from the server to the local PC but i get the following error:
****start of error message ***************
The application attempted to perform an operation not allowed by the security policy <bla bla bla>
Request for the permission of type
System.Security.Permissions.SecurityPermission, mscorlib,
Version=1.0.5000.0, Culture=neutral,
PublicKeyToken=b77a5c561934e089 failed.
******* end of error message **************
My code is the following:
*****************************************
Dim SourceFile, DestinationFile As String
Dim test As String
Dim sFileInfo As IO.FileInfo
Dim fileIOPerm1 As FileIOPermission
'fileIOPerm1 = New FileIOPermission(FileIOPermissionAccess.AllAccess, "c:\fileToBeCopied.exe")
'fileIOPerm1.Demand()
Dim f As New FileIOPermission(PermissionState.Unrestricted, "c:\fileToBeCopied.exe")
f.AllLocalFiles = FileIOPermissionAccess.AllAccess
PgbCopying.Minimum = 0
sFileInfo = New System.IO.FileInfo("j:\fileToBeCopied.exe") 'j is the server
test = sFileInfo.Length
PgbCopying.Maximum = test
SourceFile = "j:\fileToBeCopied.exe" ' Define source file name.
DestinationFile = "c:\fileToBeCopied" ' Define target file name.
FileCopy(SourceFile, DestinationFile) ' Copy source to target.
PgbCopying.Value = PgbCopying.Value + test
Timer1.Enabled = False
End
****** END OF CODE ****************
So i am trying to copy the FileToBeCopied from the J Drive to the C Drive, and while in my computer all are OK, when i go to another one i get this message. At first I used the demand command with the same result. Then i comment it out and tryed PermitionState. Nothing.Any help? Thank you...