Windows – Java service can’t list files in directories

accountsjavaservicewindows

I posted this question in Stack Overflow, and someone redirected me here:

Hello everyone. I'm doing a Windows Service in Java, this service list the files in a directory and write the results in a file. My problem is that when i call Java.File.isDirectory() when the service is running it always results false (It works well when i run the service manually as any other program). Besides, if i try the following: for(File F : directorio.listFiles()) trows an exception when i run the program as a service. I believe is permission related, because when i change the account in which the service is running to my own credentials it list the files correctly. Do you know if there is a workaround? (Change a windows policy, another kind of special account, another way to list the files of the directory, any other thing maybe i'm missing). Thanks in advance.

Best Answer

Thanks for all your help! I found my problem, i was reading the path from a configuration file which i assumed to be in the user's home (my home and System's home are not the same... my fault). Unfourtenly i didn't realize that because i was using a recycled class (:S). Again Thank you very much.

Related Topic