CopyDirectory method gives permission error

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • =?Utf-8?B?UGF0Y2g2MQ==?=

    CopyDirectory method gives permission error

    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(B yVal sender As System.Object, ByVal e As
    System.EventArg s) Handles Button1.Click
    My.Computer.Fil eSystem.CopyDir ectory("F:\WAFS Blocks - Test",
    "C:\HES\WAFS\WA FS 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.Securit y.Permissions.F ileIOPermission , mscorlib, Version=2.0.0.0 ,
    Culture=neutral , PublicKeyToken= b77a5c561934e08 9'
    ............

    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.

  • zacks@construction-imaging.com

    #2
    Re: CopyDirectory method gives permission error

    On Mar 14, 2:58 pm, Patch61 <Patc...@discus sions.microsoft .comwrote:
    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(B yVal sender As System.Object, ByVal e As
    System.EventArg s) Handles Button1.Click
            My.Computer.Fil eSystem.CopyDir ectory("F:\WAFS Blocks - Test",
    "C:\HES\WAFS\WA FS 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.Securit y.Permissions.F ileIOPermission , mscorlib, Version=2.0.0.0 ,
    Culture=neutral , PublicKeyToken= b77a5c561934e08 9'
    ...........
    >
    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.

    Comment

    • kimiraikkonen

      #3
      Re: CopyDirectory method gives permission error

      On Mar 14, 8:58 pm, Patch61 <Patc...@discus sions.microsoft .comwrote:
      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(B yVal sender As System.Object, ByVal e As
      System.EventArg s) Handles Button1.Click
              My.Computer.Fil eSystem.CopyDir ectory("F:\WAFS Blocks - Test",
      "C:\HES\WAFS\WA FS 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.Securit y.Permissions.F ileIOPermission , mscorlib, Version=2.0.0.0 ,
      Culture=neutral , PublicKeyToken= b77a5c561934e08 9'
      ...........
      >
      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.

      Comment

      • =?Utf-8?B?UGF0Y2g2MQ==?=

        #4
        Re: CopyDirectory method gives permission error

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

        "zacks@construc tion-imaging.com" wrote:
        On Mar 14, 2:58 pm, Patch61 <Patc...@discus sions.microsoft .comwrote:
        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(B yVal sender As System.Object, ByVal e As
        System.EventArg s) Handles Button1.Click
        My.Computer.Fil eSystem.CopyDir ectory("F:\WAFS Blocks - Test",
        "C:\HES\WAFS\WA FS 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.Securit y.Permissions.F ileIOPermission , mscorlib, Version=2.0.0.0 ,
        Culture=neutral , PublicKeyToken= b77a5c561934e08 9'
        ...........

        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.
        >

        Comment

        • =?Utf-8?B?UGF0Y2g2MQ==?=

          #5
          Re: CopyDirectory method gives permission error

          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.


          "kimiraikko nen" wrote:
          On Mar 14, 8:58 pm, Patch61 <Patc...@discus sions.microsoft .comwrote:
          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(B yVal sender As System.Object, ByVal e As
          System.EventArg s) Handles Button1.Click
          My.Computer.Fil eSystem.CopyDir ectory("F:\WAFS Blocks - Test",
          "C:\HES\WAFS\WA FS 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.Securit y.Permissions.F ileIOPermission , mscorlib, Version=2.0.0.0 ,
          Culture=neutral , PublicKeyToken= b77a5c561934e08 9'
          ...........

          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.
          >

          Comment

          • Chris Dunaway

            #6
            Re: CopyDirectory method gives permission error

            On Mar 14, 1:58 pm, Patch61 <Patc...@discus sions.microsoft .comwrote:
            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(B yVal sender As System.Object, ByVal e As
            System.EventArg s) Handles Button1.Click
            My.Computer.Fil eSystem.CopyDir ectory("F:\WAFS Blocks - Test",
            "C:\HES\WAFS\WA FS 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.Securit y.Permissions.F ileIOPermission , mscorlib, Version=2.0.0.0 ,
            Culture=neutral , PublicKeyToken= b77a5c561934e08 9'
            ...........
            >
            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

            Comment

            Working...