Stanley Mungai
Stanley Mungai

Reputation: 4150

Create a File that cannot be deleted Java

Hi guys I am Using CreateNewFile() function to make a .txt file I them Hide it using the Following Code In System32 Directory.

Process p = Runtime.getRuntime().exec("attrib +h " + f.getPath());
p.waitFor();  

The File is getting Hidden successfully But I need it to be secure so that you cannot delete it even if you wanted to. Is there a way to achieve this Programmatically?

Upvotes: 0

Views: 1036

Answers (2)

amicngh
amicngh

Reputation: 7899

I don't think so You can do it. Every file can be deleted somehow in windows(booting in safe mode).

Upvotes: 2

Amit Deshpande
Amit Deshpande

Reputation: 19185

The only way is to use Username while creating File. You can not delete file created by other user unless you are administrative.

You will find More information Undeletable Folder in java

Upvotes: 0

Related Questions