2
Answers

Problem while saving a file to Diffrenet server or Machine using windows service?

Ask a question
R

R

14y
4k
1


Hi
I implemeted a windows service.It was installed on a "Machine A" .
The job of this service is read a  file from a specified folder in "Machine A"  and move it to "Machine B"'s Shared folder.
"Machine B"'S Shared folder having full rights for a "User A". and i am imporsinating with "User A"  to move file from "MACHINE A" to "MACHINE B".
It's throwing "Access Denied Error" Please let me know what went wrong with this?
 private void MoveFile(FileInfo file)
        {
            try
            {
                if (objImp.impersonateValidUser())//immporsinate with user A
                    file.MoveTo("\\\\Machine B\\Shared Folder\\" + file.Name);
            }
            catch (Exception ex)
            {
                //Saev error message
            }
            finally
            {
                objImp.undoImpersonation();
            }
           
        }
 
Thanks
Rakesh
 

Answers (2)