Here's a tough one

  • Thread starter Thread starter JmJimRockford39
  • Start date Start date
J

JmJimRockford39

Does anyone know how to set a simple .txt file so that no one can delete or
modify it, even through Explorer? I still need to be able to modify or delete
it through my vb.net program though. Hmmmmmmmm....is this a tough one?
 
Open the file thru your vb.net code for writing. This is how you will
lock it & hence the file wont be deleted thru explorer & you can do
anything with it

Though, if your prog is closed, the lock will be released & it is free
Som your prog must be running & shd have a lock acquired

Kalpesh
 
Hi,
Once the application starts, you could lock the file. This way, the file
cannot be deleted as long as the app is running. The file can still can be
deleted once the application is closed.

You could also create a windows service that locks the file. This way,
though the application is closed, the file cannot be deleted through the
explorer. The difficult part here is how does the application communicate
with the service. You can achieve this by making the windows service(that
locks the file) listen to a particular port and your application could send
messages(to modify or delete) through this port.

Hope this helps.

Regards,
Sankalp
 
* (e-mail address removed) (JmJimRockford39) scripsit:
Does anyone know how to set a simple .txt file so that no one can delete or
modify it, even through Explorer? I still need to be able to modify or delete
it through my vb.net program though. Hmmmmmmmm....is this a tough one?

Have a look at 'Microsoft.VisualBasic.FileSystem.FileOpen'. Set the the
'Share' parameter to 'LockReadWrite'.

--
Herfried K. Wagner
MVP · VB Classic, VB.NET
<http://www.mvps.org/dotnet>

<http://www.plig.net/nnq/nquote.html>
 
Does anyone know how to set a simple .txt file so that no one can delete or
modify it, even through Explorer? I still need to be able to modify or delete
it through my vb.net program though. Hmmmmmmmm....is this a tough one?

Perhaps you could set it's read only flag. Then, when your program starts,
clear the read only flag while you are editing it, but when you are done,
restore the flag.

This will not stop someone from clearing the Read Only flag through
explorer and then deleting the file, but they would not be able to do so
accidentally.
 
Back
Top