Click here to Skip to main content
13,052,696 members (65,632 online)
Rate this:
Please Sign up or sign in to vote.
See more:
Hi all

I have a emploee photos in a network folder .I want to copy all files from this network folder to local machine folder.Can Anybody paste code for that or check my code and mention whats the problem with that code and how to change
                UserImpersonation impersonator = new UserImpersonation();
                impersonator.impersonateUser("username", "", "password"); //No Domain is required
                List<FileInfo> OcDialerlfinfo = null;
                OcDialerlfinfo = GetFileList("*", "\\\\\\hrmsfiles\\Photo");
                foreach (FileInfo fileName in OcDialerlfinfo)
                    string targetFolder = "D:/Share/photo1";
                    string fileName1 = fileName.ToString();
                   string destFile1 = fileName.DirectoryName+"\\"  +fileName1;
                 FileInfo fi = new FileInfo(destFile1);
                   fi.CopyTo(System.IO.Path.Combine(targetFolder, fi.Name), true);

error happening as "Logon failure: unknown user name or bad password." .Iam getting files from network folder but cant copy to local.error arising in last line.What's the problem?
Thanks in Advance

[Edit]Code block added[/Edit]
Posted 29-Mar-13 0:53am
Updated 29-Mar-13 1:00am
Dnyaneshwar Kondbale 29-Mar-13 7:19am
I think you try to give full access to the directory "D:/Share/photo1"
ryanb31 29-Mar-13 8:08am
The error tells you what is wrong.
amritha444 29-Mar-13 8:16am
Yes I already gave full access to D:/Share/photo1".I can copy a file from local machine to the same machines another folder well.problem happening when copying from network folder

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
Top Experts
Last 24hrsThis month

Advertise | Privacy | Mobile
Web02 | 2.8.170713.1 | Last Updated 29 Mar 2013
Copyright © CodeProject, 1999-2017
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100