Click here to Skip to main content
15,892,298 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
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
C#
                UserImpersonation impersonator = new UserImpersonation();
                impersonator.impersonateUser("username", "", "password"); //No Domain is required

                List<FileInfo> OcDialerlfinfo = null;
                OcDialerlfinfo = GetFileList("*", "\\\\192.xxxc.0.cc\\hrmsfiles\\Photo");
                impersonator.undoimpersonateUser();
                Console.Read();
              
                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
Amritha

[Edit]Code block added[/Edit]
Posted
Updated 29-Mar-13 1:00am
v2
Comments
Dnyaneshwar Kondbale 29-Mar-13 7:19am    
I think you try to give full access to the directory "D:/Share/photo1"
ZurdoDev 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)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900