I am new to .Net programming, but I am experienced with VB6. I am using VB
2008 Express to write a small program to copy a directory structure and files
from a CD to a folder on C: drive.

I have a form with 2 buttons; one to do the copying and one to cancel.

Here is my code for the copying button:

Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles Button1.Click
My.Computer.FileSystem.CopyDirectory("F:\WAFS Blocks - Test",
"C:\HES\WAFS\WAFS Blocks", FileIO.UIOption.AllDialogs)
End Sub

When I click button1, I get an error that says:

...........
Application attempted to perform an operation not allowed by the security
policy. To grant this application the required permission, contact your
system administrator, or use the Microsoft .NET Framework Configuration tool.

Request for the permission of type
'System.Security.Permissions.FileIOPermission, mscorlib, Version=2.0.0.0,
Culture=neutral, PublicKeyToken=b77a5c561934e089'
...........

My IT department has no idea what to do about this. They have given my user
account full admin rights with the same results.

What do I need to do to correct this? I need to deploy this on several
systems in several office locations.

Thanks in advance for any help.

Re: CopyDirectory method gives permission error by zacks

zacks
Fri Mar 14 14:28:30 CDT 2008

On Mar 14, 2:58=A0pm, Patch61 <Patc...@discussions.microsoft.com> wrote:
> I am new to .Net programming, but I am experienced with VB6. I am using VB=

> 2008 Express to write a small program to copy a directory structure and fi=
les
> from a CD to a folder on C: drive.
>
> I have a form with 2 buttons; one to do the copying and one to cancel.
>
> Here is my code for the copying button:
>
> =A0 =A0 Private Sub Button1_Click(ByVal sender As System.Object, ByVal e A=
s
> System.EventArgs) Handles Button1.Click
> =A0 =A0 =A0 =A0 My.Computer.FileSystem.CopyDirectory("F:\WAFS Blocks - Tes=
t",
> "C:\HES\WAFS\WAFS Blocks", FileIO.UIOption.AllDialogs)
> =A0 =A0 End Sub
>
> When I click button1, I get an error that says:
>
> ...........
> Application attempted to perform an operation not allowed by the security
> policy. To grant this application the required permission, contact your
> system administrator, or use the Microsoft .NET Framework Configuration to=
ol.
>
> Request for the permission of type
> 'System.Security.Permissions.FileIOPermission, mscorlib, Version=3D2.0.0.0=
,
> Culture=3Dneutral, PublicKeyToken=3Db77a5c561934e089'
> ...........
>
> My IT department has no idea what to do about this. They have given my use=
r
> account full admin rights with the same results.
>
> What do I need to do to correct this? I need to deploy this on several
> systems in several office locations.
>
> Thanks in advance for any help.

I have never used this method, and doubt I ever will now since I have
switched to C#.NET. But, looking as MSDN help, in the list of
exceptions that this method can raise, one is "The Source Directory is
a root directory". Now the remarks does not explicitely mention that
the source direcotyr cannot be the root directory, but it makes one
wonder.

Re: CopyDirectory method gives permission error by kimiraikkonen

kimiraikkonen
Fri Mar 14 18:57:24 CDT 2008

On Mar 14, 8:58=A0pm, Patch61 <Patc...@discussions.microsoft.com> wrote:
> I am new to .Net programming, but I am experienced with VB6. I am using VB=

> 2008 Express to write a small program to copy a directory structure and fi=
les
> from a CD to a folder on C: drive.
>
> I have a form with 2 buttons; one to do the copying and one to cancel.
>
> Here is my code for the copying button:
>
> =A0 =A0 Private Sub Button1_Click(ByVal sender As System.Object, ByVal e A=
s
> System.EventArgs) Handles Button1.Click
> =A0 =A0 =A0 =A0 My.Computer.FileSystem.CopyDirectory("F:\WAFS Blocks - Tes=
t",
> "C:\HES\WAFS\WAFS Blocks", FileIO.UIOption.AllDialogs)
> =A0 =A0 End Sub
>
> When I click button1, I get an error that says:
>
> ...........
> Application attempted to perform an operation not allowed by the security
> policy. To grant this application the required permission, contact your
> system administrator, or use the Microsoft .NET Framework Configuration to=
ol.
>
> Request for the permission of type
> 'System.Security.Permissions.FileIOPermission, mscorlib, Version=3D2.0.0.0=
,
> Culture=3Dneutral, PublicKeyToken=3Db77a5c561934e089'
> ...........
>
> My IT department has no idea what to do about this. They have given my use=
r
> account full admin rights with the same results.
>
> What do I need to do to correct this? I need to deploy this on several
> systems in several office locations.
>
> Thanks in advance for any help.

If you're copying the file over a LAN, having full admin rights will
not help you. Check for sharing / security permissions depending your
operating system.

If it's a local disk, try to copy the same directory manually (copy-
paste) and see if error happens again.

Re: CopyDirectory method gives permission error by Patch61

Patch61
Fri Mar 14 21:28:00 CDT 2008

Thank you for replying, but as you can see from my code, neither the source
nor the destination is a root directory.

"zacks@construction-imaging.com" wrote:

> On Mar 14, 2:58 pm, Patch61 <Patc...@discussions.microsoft.com> wrote:
> > I am new to .Net programming, but I am experienced with VB6. I am using VB
> > 2008 Express to write a small program to copy a directory structure and files
> > from a CD to a folder on C: drive.
> >
> > I have a form with 2 buttons; one to do the copying and one to cancel.
> >
> > Here is my code for the copying button:
> >
> > Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As
> > System.EventArgs) Handles Button1.Click
> > My.Computer.FileSystem.CopyDirectory("F:\WAFS Blocks - Test",
> > "C:\HES\WAFS\WAFS Blocks", FileIO.UIOption.AllDialogs)
> > End Sub
> >
> > When I click button1, I get an error that says:
> >
> > ...........
> > Application attempted to perform an operation not allowed by the security
> > policy. To grant this application the required permission, contact your
> > system administrator, or use the Microsoft .NET Framework Configuration tool.
> >
> > Request for the permission of type
> > 'System.Security.Permissions.FileIOPermission, mscorlib, Version=2.0.0.0,
> > Culture=neutral, PublicKeyToken=b77a5c561934e089'
> > ...........
> >
> > My IT department has no idea what to do about this. They have given my user
> > account full admin rights with the same results.
> >
> > What do I need to do to correct this? I need to deploy this on several
> > systems in several office locations.
> >
> > Thanks in advance for any help.
>
> I have never used this method, and doubt I ever will now since I have
> switched to C#.NET. But, looking as MSDN help, in the list of
> exceptions that this method can raise, one is "The Source Directory is
> a root directory". Now the remarks does not explicitely mention that
> the source direcotyr cannot be the root directory, but it makes one
> wonder.
>

Re: CopyDirectory method gives permission error by Patch61

Patch61
Fri Mar 14 21:31:01 CDT 2008

Thank you for replying. I have tried this with both a network source and a
local source with the same results. I have full admin access/permissions.


"kimiraikkonen" wrote:

> On Mar 14, 8:58 pm, Patch61 <Patc...@discussions.microsoft.com> wrote:
> > I am new to .Net programming, but I am experienced with VB6. I am using VB
> > 2008 Express to write a small program to copy a directory structure and files
> > from a CD to a folder on C: drive.
> >
> > I have a form with 2 buttons; one to do the copying and one to cancel.
> >
> > Here is my code for the copying button:
> >
> > Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As
> > System.EventArgs) Handles Button1.Click
> > My.Computer.FileSystem.CopyDirectory("F:\WAFS Blocks - Test",
> > "C:\HES\WAFS\WAFS Blocks", FileIO.UIOption.AllDialogs)
> > End Sub
> >
> > When I click button1, I get an error that says:
> >
> > ...........
> > Application attempted to perform an operation not allowed by the security
> > policy. To grant this application the required permission, contact your
> > system administrator, or use the Microsoft .NET Framework Configuration tool.
> >
> > Request for the permission of type
> > 'System.Security.Permissions.FileIOPermission, mscorlib, Version=2.0.0.0,
> > Culture=neutral, PublicKeyToken=b77a5c561934e089'
> > ...........
> >
> > My IT department has no idea what to do about this. They have given my user
> > account full admin rights with the same results.
> >
> > What do I need to do to correct this? I need to deploy this on several
> > systems in several office locations.
> >
> > Thanks in advance for any help.
>
> If you're copying the file over a LAN, having full admin rights will
> not help you. Check for sharing / security permissions depending your
> operating system.
>
> If it's a local disk, try to copy the same directory manually (copy-
> paste) and see if error happens again.
>

Re: CopyDirectory method gives permission error by Chris

Chris
Mon Mar 17 09:59:02 CDT 2008

On Mar 14, 1:58 pm, Patch61 <Patc...@discussions.microsoft.com> wrote:
> I am new to .Net programming, but I am experienced with VB6. I am using VB
> 2008 Express to write a small program to copy a directory structure and files
> from a CD to a folder on C: drive.
>
> I have a form with 2 buttons; one to do the copying and one to cancel.
>
> Here is my code for the copying button:
>
> Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As
> System.EventArgs) Handles Button1.Click
> My.Computer.FileSystem.CopyDirectory("F:\WAFS Blocks - Test",
> "C:\HES\WAFS\WAFS Blocks", FileIO.UIOption.AllDialogs)
> End Sub
>
> When I click button1, I get an error that says:
>
> ...........
> Application attempted to perform an operation not allowed by the security
> policy. To grant this application the required permission, contact your
> system administrator, or use the Microsoft .NET Framework Configuration tool.
>
> Request for the permission of type
> 'System.Security.Permissions.FileIOPermission, mscorlib, Version=2.0.0.0,
> Culture=neutral, PublicKeyToken=b77a5c561934e089'
> ...........
>
> My IT department has no idea what to do about this. They have given my user
> account full admin rights with the same results.
>
> What do I need to do to correct this? I need to deploy this on several
> systems in several office locations.
>
> Thanks in advance for any help.

Where is the program running? Are you running it from a network
share? Or is the program located on the local hard drive? If running
from a network share, you need to grant trust to the application.

F: looks like a mapped drive. You might try copying using the full
UNC of the path instead of the mapped drive.

Good Luck

Chris