Windows Service Cannot Move Files

  • Thread starter Thread starter dermot
  • Start date Start date
D

dermot

I have wrriten a small windows service application in visual studio
..net 2003 which listens for incoming FTP files.
These files would overwrite over time due to duplicate file names.
However any time the windows service tries to rename the file (using
flFile.move(source,destination)) it gets an error saying access is
denied.

The files are on the network, so we though the local system account may
not have access
We tried changing the account the service uses to a domain admin, but
still got the same error.

The application runs fine as VB windows form

Any ideas, why windows service cannot do the same.

Many Thanks
Dermot French
 
Windows services, by default, don't have access to the network. In w2k and
XP there is a network version of the system account you can use.

Mike Ober.
 
Mike,
I actually changed the account that starts it to a domain admin
account. It can see the files (which the local system could not) -
however it cannot move the files (gets the access denied message)?

The services is running on a win 2003 server machine.
Any ideas

Regards,
Dermot
 
hi dermot

I think you are trying to get the files while they are still used by
the tcp.

You should allow some delay. When a file arrives do not assault it !

Place a timer and make an attempt every half second. You will see
some attempt will eventually succeed. Can place a limit to the number
of
attempts and log the possible unsuccesses.... let me know

-tom

dermot ha scritto:
 
That isn't the problem
It uses a notify filter, for last write and then delays

This works fine using exact same code from a Windows form application
(just doesn't work when I change it to Windows Services Application).

Regards,
Dermot
 
Watch out for using mapped drive letters. These are done on a
user-by-user basis when they log in. Try using the full network path
(like //corp_server/datadir/targetfile.txt) and see if that helps.

Tom
 
I am using the full network path
The windows service can see the original files, it just cannot rename
them

Any ideas?
 
Are you sure that the account has write access to the directory and files?
Sounds like it only has read access.

/claes
 
It is a domain admin account, and has also been given all rights on the
folder in question.
 
Please verify both the share permissions and the NTFS permissions. I had a
similar problem and my share permissions were wrong.

Mike Ober.
 
It was permissions, the person who installed it had no put it under the
correct account.

Thanks for the help - it is now working
 
Back
Top