Click here to Skip to main content
Rate this: bad
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("*", "\\\\\\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 1:53am
Edited 29-Mar-13 2:00am
(no name)145.5K
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)

Advertise | Privacy | Mobile
Web01 | 2.8.150326.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