Re: File Copy

Tech-Archive recommends: Fix windows errors by optimizing your registry



Hello Pavel,

Many thanks for your suggestions.

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

Regards....Adrian

"Pavel Minaev" wrote:

On Jul 31, 11:40 pm, AdrianMorris
<AdrianMor...@xxxxxxxxxxxxxxxxxxxxxxxxx> wrote:
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\temp" (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 programmatically 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.

.



Relevant Pages

  • Re: File Copy
    ... have permission with my current logon details to access. ... If I open the folder using the Windows file manager with the path "\\ ... If I enter valid details, ... Try using WindowsIdentity.Impersonate() to impersonate the user ...
    (microsoft.public.dotnet.languages.vc)
  • RE: CreateDirectory() - Could not find a part of the path "D:".
    ... we may do some check on permission. ... through passing full qualified path when you swtich the process identity ... and turn off impersonate). ... BTW, to get the physical path of the root dir of our ASP.NET application, ...
    (microsoft.public.dotnet.framework.aspnet)
  • Re: asp.net and ldap
    ... you still use impersonate and grant the impersonated user the access ... permission to the folder you want to write? ... | permissions to the aspnet account, so it could upload images to a folder. ... |> I use this code to try to connect to ldap: ...
    (microsoft.public.dotnet.framework.aspnet)
  • Re: File Copy from a Remote Server
    ... have permission with my current logon details to access. ... If I open the folder using the Windows file manager with the path "\\ ...
    (microsoft.public.dotnet.languages.csharp)
  • Re: How to read a file from a different drive on the same machine C# windows based application
    ... You do not have permission to read. ... You'll need to either impersonate the user accessing your ... I do not answer questions on behalf of my employer. ... programmer helping programmers. ...
    (microsoft.public.dotnet.languages.csharp)