Click here to Skip to main content
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 1:53am
Edited 29-Mar-13 2:00am
(no name)131.8K
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 George Jonsson 175
1 Kornfeld Eliyahu Peter 169
2 Zoltán Zörgő 139
3 PIEBALDconsult 130
4 OriginalGriff 120
0 OriginalGriff 6,165
1 DamithSL 4,658
2 Maciej Los 4,107
3 Kornfeld Eliyahu Peter 3,649
4 Sergey Alexandrovich Kryukov 3,342


Advertise | Privacy | Mobile
Web01 | 2.8.141220.1 | Last Updated 29 Mar 2013
Copyright © CodeProject, 1999-2014
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