Recently, a Windows Service was developed to synchronize files between shared directories.
Considering that, during the COPY process, if the network suddenly fails to be accessed, the file COPY is incomplete, We will discard the COPY method provided by. Net and use the XCOPY command under the doscommand.
Well ..... Just do it...
Verify, develop, and debug the XCOPY solution (two shared directories are created on your computer ).... Half a day, all done. It seems that things are going too smoothly .....
Since local debugging is okay, deploy it to the test environment. Okay... The problem arises.
An error occurred while synchronizing the two shared directories! Check the log. The XCOPY exit code ExitCode is 4, which means the path is incorrect.
Strange .... No reason ........ On the test server, the \ IP \ secure folder method is accessible and can be read and written normally.
Run the XCOPY command that failed synchronization in the CMD window. It succeeded ......
When you see this, you may also think that Windows Service has no permission to access and share.
Google ..... Google ....... Find the method for adding permissions.
Reference: http://stackoverflow.com/questions/9905281/how-to-access-to-a-shared-resource-with-a-windows-service-using-local-system-use
The procedure is as follows:
1) First, find the user with the read and write permissions of the shared directory.
2) In the properties of Windows Service, select the "login" tab and under "this user", give a user with the permission to read and write the shared directory.
3) Click OK to restart the service.
Well, with an exciting heart, restart, re-Synchronize, and continue to fail ............. OH, Miss !!!!!!!!!!!!!!
Isn't that just adding a user to the service ...... Cheat paper .........
Continue Google... Google .... Google ..................
I have to say that Stackoverflow has a lot of scalpers...
USE the net use command to create and share a link
Usage: Net Use \ ServerIP \ login folder Password/USER: User
Don't talk nonsense. Hurry up and try .....
Command completed successfully .... With excitement, restart the service ..... Synchronization successful !!!