Click here to Skip to main content
11,577,965 members (61,417 online)
Rate this: bad
good
Please Sign up or sign in to vote.
See more: C#
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("*", "\\\\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 29-Mar-13 0:53am
Edited 29-Mar-13 1:00am
(no name)159.6K
v2
Comments
Dnyaneshwar Kondbale at 29-Mar-13 7:19am
   
I think you try to give full access to the directory "D:/Share/photo1"
ryanb31 at 29-Mar-13 8:08am
   
The error tells you what is wrong.
amritha444 at 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
0 OriginalGriff 165
1 Richard MacCutchan 165
2 Peter Leow 160
3 Afzaal Ahmad Zeeshan 125
4 Frankie-C 85
0 OriginalGriff 880
1 Sergey Alexandrovich Kryukov 685
2 Abhinav S 573
3 F-ES Sitecore 420
4 Suvendu Shekhar Giri 393


Advertise | Privacy | Mobile
Web04 | 2.8.150603.1 | Last Updated 29 Mar 2013
Copyright © CodeProject, 1999-2015
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