Windows Service Cannot Move Files

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
 
M

Michael D. Ober

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.
 
D

dermot

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
 
T

tommaso.gastaldi

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:
 
D

dermot

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
 
T

TDC

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
 
D

dermot

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

Any ideas?
 
C

Claes Bergefall

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

/claes
 
D

dermot

It is a domain admin account, and has also been given all rights on the
folder in question.
 
M

Michael D. Ober

Please verify both the share permissions and the NTFS permissions. I had a
similar problem and my share permissions were wrong.

Mike Ober.
 
D

dermot

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

Thanks for the help - it is now working
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top