Tom's Guide | Tom's Hardware | Tom's Games
![]() |
![]() |
![]() |
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...

I don't know if it is a programming issue. It might be that the computer where you get the error does not have those permissions on the target computer.
Are you logged into the network on the computer using an account that has those permissions on the target computer?
You might want to check the permissions on the source and target drives and folders.
I hope this helps some.
Chi
"They mostly come at night...mostly"

Hello Chi,
I gave full permissions to the user for the directory where the file is, but still nothing. If I use VB6 I don't have that problem.
The user is logging in as "User" and not as "Administrator" as I do. Is that has anything to do with that? Like I said I have given him full rights.
Thank you for your reply. I am still trying to find a solution...

![]() |
![]() |
![]() |

This post is quite old and has been locked from receiving new replies. Please create a new posting instead.
| Ads by Google |