Click here to Skip to main content
15,885,546 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
I am trying to Make Content Of One Folder Secured
So My Goal Is to build batch file or small program that can delete all content in that Folder If Some One Open Or Copy It.

No Limitation In Technologies or programming techiques or languages.
USING C# , Java, C++, Batch-Files or other ways dosent matter
So Any Scripts Or Ideas Will be Appreciated .

Thanks..
Posted
Updated 22-Jan-14 11:23am
v2
Comments
Sergey Alexandrovich Kryukov 22-Jan-14 21:24pm    
Why, I wonder? Here is the problem: there is not such concept as "open a folder". This nothing but a UI metaphor. Even the notion of "folder" is a UI metaphor, there are only "directories". Detecting when a file is open (for, example, for copying) is in principle possible, but not easy...
—SA
osamaworx 23-Jan-14 5:37am    
mmmm , ok what I mean Is that any way to attatch action /event handller to that event ---> (Accessing specific Directory without my application)
in any level of programming languages or using batch files or by providing un breakable security rights on that folder ??
[no name] 22-Jan-14 21:24pm    
What is the purpose of a folder whose contents are deleted when access is attempted?
For example I could prevent theft by blowing up my house whenever someone enters. Does that sound logical?
RaviRanjanKr 22-Jan-14 22:37pm    
If so then what is the use of that folder ;)
ravikhoda 22-Jan-14 23:07pm    
this is more related to network and security rather than the programming. try to give permisiion on that folder using security tab in the property. you can even use some third party tools like folder lock or filemananger or something for this purpose. you can also hide that folder if you do not wish others to open that folder.

1 solution

After reading through the comments, the question should be updated.

This answer is Windows specific.

You can create a temporary file with exclusive read and exclusive write access AND set the file to be deleted when closed by your application.

See this link:
http://msdn.microsoft.com/en-us/library/windows/desktop/aa363858%28v=vs.85%29.aspx[^]

Use zero for share mode (exclusive). Include FILE_FLAG_DELETE_ON_CLOSE for the flags parameter.

Leave the file open while your application is running. Just before you close the file, wipe the file contents.

This isn't 100% but covers most cases. If the device is powered off while the file exists, the data is still there.

A better solution (though not your original question) would be to decrypt only the portions needed and retain them in memory.
 
Share this answer
 
Comments
osamaworx 24-Jan-14 14:32pm    
Thanks I think that will help ,I am still reading
osamaworx 24-Jan-14 14:33pm    
its based on C++ Only , yes ? No C#
[no name] 24-Jan-14 15:34pm    
C# should have an equivalent. Here's a possibility.

System.IO.File.Create("path", 65536, System.IO.FileOptions.DeleteOnClose);

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900