How do I use deleteFile () with an argument that contains a path separator?
The application implements a method deleteFile(String path)
that should delete the file located at the specified path.
If the path contains a path separator (character /
), the method throws an exception, but the full path must be used and must contain a separator character to delete a specific file. Due to conflicting conditions, I have not found a way to successfully delete the file.
Does anyone know how to get around the problem?
source to share
Not knowing which exception is hard to say. In general, it's best to avoid hardcoding path delimiters and use character instead File.separator
.
How are you going to delete the file? The File class has a delete method; is this what you are using?
I am guessing that the problem may not actually be related to the things I mentioned and should be resolved instead. Are you trying to access files or directories that your program does not have permission to access?
source to share