R

R

  • NA
  • 8
  • 0

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

Nov 6 2009 6:22 AM


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)