473,395 Members | 1,681 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,395 software developers and data experts.

Stopping A File From Being Deleted

Jay
Hey There,
Is there a way to write code that will protect a file such that
when a user tries to delete it, it will be protected with the "Cannot
delete 'xyz': Access is denied. Make sure the disk is not full or
write-protected and that the file is not currently in use.". Also, how
would you programatically do the reverse? Have a code remove what
protection there is from a file that has that set?

Thank you for the prompt response,
Jay
(patelj27b at gmail dot com)
P.S. I just want to thank all the people out there that have been
prompt in answering my previous questions. It is great to know that
there is always a source out there that can help me gain a better
insight into Windows C++ programming.

May 12 '06 #1
2 961
"Jay" wrote:
Hey There,
Is there a way to write code that will protect a file such that
when a user tries to delete it, it will be protected with the "Cannot
delete 'xyz': Access is denied. Make sure the disk is not full or
write-protected and that the file is not currently in use.". Also, how
would you programatically do the reverse? Have a code remove what
protection there is from a file that has that set?


There's actually about 5 or 6 different ways to do this, depending on how
much control you need to have and what programming model you are using
(Win32, MFC, COM, C++/CLI).

Here's the link to the start of one of the relevant MSDN Library sections:

http://msdn.microsoft.com/library/de...asp?frame=true

It's not terribly difficult once you learn the terminology and concepts, but
it can be pretty overwhelming at first.

Sean

May 12 '06 #2
Jay
Sean,
Thanks for the link, it helped me get something running that I
wanted, but I have two questions:
1). When I reboot the machine, the Access Rights go back to the
previous settings, how do I get the modified Access Rights to stick
across reboots?
2). Also, is this information kept in the registry? If so, where in
the registry is it kept?

Thanks,
Jay
(patelj27b at gmail dot com)

May 15 '06 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

9
by: Paul | last post by:
Hi, VB.NET is saying the file I am creating is in use by another process and won't complete its task of moving the file to the specified destination folder. Here is my code (the main bit...
5
by: David Webb | last post by:
The problem started when the Working Folder for a project was somehow set to the folder of another project. I set the correct working folder in VSS and deleted the .vbproj files that had been...
12
by: Riley DeWiley | last post by:
I have a project that is using a Jet backend and having trouble with Jet's tendency to bloat it's MDB file. I can compact it but it is a hassle. I am considering switching to a Fox backend but have...
6
by: Kiran | last post by:
Hi, I have program, which opens file at the startup and logs error messages to the file, file handle is closed at the end of the program. However if file is deleted in-between, program do not...
6
by: Ana | last post by:
Hi! I have problems with the following scenario: My application is developed using C# under .NET. It must run on all Windows versions starting from Windows 98. The user must open different...
5
by: Jon Maz | last post by:
Hi there, I am experimenting with the FileSystemWatcher object. I have set the NotifyFilter as follows: myFileSystemWatcher.NotifyFilter = NotifyFilters.Security | NotifyFilters.CreationTime...
0
by: Jay | last post by:
Hey There, Is there a way to write code that will protect a file such that when a user tries to delete it, it will be protected with the "Cannot delete 'xyz': Access is denied. Make sure the disk...
2
by: Mark | last post by:
I have a form with two sub forms. The form is set to data entry. The form is bound directly to a table I have two buttons at the bottom of the screen. One button is named reject and one is named...
6
by: shyam | last post by:
Hi All I had raised a simillar query in an earlier post ...
6
by: Zytan | last post by:
I ran through the VB Guided Tour some time ago. In particular, the "Managing Your Records: Using Data in Your Program" section: http://msdn2.microsoft.com/en-us/library/t25kbx0s(VS.80).aspx ...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.