File Copy

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

    File Copy

    Hello!

    I'm trying to copy a file from another computer on the network that I do not
    have permission with my current logon details to access.

    If I open the folder using the Windows file manager with the path "\\
    192.168.2.2\tem p" (where temp is a shared directory on server \\192.168.2.2),
    windows prompts for a User Name and password of a user who has permission on
    that computer to access that directory. If I enter valid details, the folder
    is opened and I can copy files from this machine.

    How do I do this programmaticall y in c++ or c#? Standard file open and/or
    directory commands do not have the option to enter a valid Username/password
    and they just fails with permission denied (understandably ).

    Regards....Adri an

  • Pavel Minaev

    #2
    Re: File Copy

    On Jul 31, 11:40 pm, AdrianMorris
    <AdrianMor...@d iscussions.micr osoft.comwrote:
    Hello!
    >
    I'm trying to copy a file from another computer on the network that I do not
    have permission with my current logon details to access.
    >
    If I open the folder using the Windows file manager with the path "\\
    192.168.2.2\tem p" (where temp is a shared directory on server \\192.168.2..2) ,
    windows prompts for a User Name and password of a user who has permissionon
    that computer to access that directory. If I enter valid details, the folder
    is opened and I can copy files from this machine.
    >
    How do I do this programmaticall y in c++ or c#? Standard file open and/or
    directory commands do not have the option to enter a valid Username/password
    and they just fails with permission denied (understandably ).
    Try using WindowsIdentity .Impersonate() to impersonate the user
    account you want to use to access files, and invoke File.Copy when
    impersonated.

    Comment

    • =?Utf-8?B?QWRyaWFuTW9ycmlz?=

      #3
      Re: File Copy

      Hello Pavel,

      Many thanks for your suggestions.

      I used the "LogonUser" followed by the "ImpersonateLog gedOnUser" functions
      and all is working well.

      Regards....Adri an

      "Pavel Minaev" wrote:
      On Jul 31, 11:40 pm, AdrianMorris
      <AdrianMor...@d iscussions.micr osoft.comwrote:
      Hello!

      I'm trying to copy a file from another computer on the network that I do not
      have permission with my current logon details to access.

      If I open the folder using the Windows file manager with the path "\\
      192.168.2.2\tem p" (where temp is a shared directory on server \\192.168.2..2) ,
      windows prompts for a User Name and password of a user who has permission on
      that computer to access that directory. If I enter valid details, the folder
      is opened and I can copy files from this machine.

      How do I do this programmaticall y in c++ or c#? Standard file open and/or
      directory commands do not have the option to enter a valid Username/password
      and they just fails with permission denied (understandably ).
      >
      Try using WindowsIdentity .Impersonate() to impersonate the user
      account you want to use to access files, and invoke File.Copy when
      impersonated.
      >

      Comment

      Working...