tags:

views:

425

answers:

2

Hi,

In the application there is deleteFile(String path) method implemented which has to delete the file located at the given path.

If the path contains pah separator (char '/') the method throws an exception but to delete a specific file a full path has to be used and it contains a separator sign. Due to conflicting condition I haven't found a way to successfully delete the file.

Does anyone know how is it possible to bypass the problem?

Thanks!

A: 

Without knowing what the exception is it is hard to say. In general it is best to avoid hardcoding path separators and instead use the File.separator symbol.

How are you going about deleting the File? The File class has a delete method; is that what you are using?

I'm guessing the problem might actually be unrelated to the things I mentioned up top, and instead be due to permissions. Are you trying to access files or directories that your program has no right to access?

I82Much
A: 

According to javadoc of Application.deleteFile path couldn't contain path separator which is : at Unix and ; at Windows, so at least according to java doc you can delete file with a full path. Edit: '\' is File.separtor not pathSeparator.

Nikolay Ivanov