mfc >> Deleting files held open

by Al » Thu, 27 Nov 2003 20:10:59 GMT

Is it possible under Windows (98/2000/NT/XP) to
programatically delete a file that another process is
holding open, without first killing the offending process?

--- Al.



mfc >> Deleting files held open

by Al » Fri, 28 Nov 2003 17:21:55 GMT



process?
undocumented

Its for some disaster-recovery software. I don't know the
exact details so the following description is probably
full of missunderstandings!

Apparantly, we're trying to make some registry changes (I
think to do with recovery onto a system with different
hardware to the original, failed system). If another
process is looking at a particular registry branch, it
generates a log file which confuses whatever it is we are
trying to do. So we need to kill the log file. I assume
that the implications for the other process are not fatal.

--- Al.




mfc >> Deleting files held open

by xmontyx » Sat, 29 Nov 2003 18:19:53 GMT

its obsurd if another process is using a file and by SOME way you
delete it then the other process will surely crash bringing down the
whole system and
you should't even kill the process who is using it (NOT NICE :) )

what you could do is probably mark the file for deletion on the next
reboot




Deleting files held open

by Alexander Grigoriev » Sat, 29 Nov 2003 23:59:27 GMT

Some people are too quick for predicting a system crash.

There are a few cases.
1. A process opened a file with FILE_SHARE_DELETE flag. Another process is
allowed to delete the file, which will be physically deleted only when a
last handle to it is closed.
2. A file is opened without FILE_SHARE_DELETE. No other process is allowed
to delete it.
3. A remote executable file is opened and mapped as an EXE or DLL image, and
the network connection is lost. A process may get INPAGE_ERROR exception and
will probably be killed.

Neither of those scenarios would bring the system down.









Deleting files held open

by xmontyx » Mon, 01 Dec 2003 18:27:09 GMT

don't want to get in an argument here but it is a bad idea !

the guy wanted to delete a file even if it is opened without
FILE_SHARE_DELETE flags and asking for any undocumented ways to delete
it
EVEN IF there is such a way of deleting files , the system Stability
will be threatened ,
but there are programmers out there who don't really care









Deleting files held open

by David Crow [MCSD] » Tue, 02 Dec 2003 05:05:39 GMT

Have you looked at MoveFileEx(..., MOVEFILE_DELAY_UNTIL_REBOOT)?







Similar Threads

1. Deleting files that are being held by a program

2. Open previously opened serialized file != new open serialize file

3. How to delete pointers held inside a vector

Hi,

I have a class named MC.

Header contains the following:

struct tCDV
 {
  int intC
  long lngR;
  bool blnE;
  CString strC;
 };
 tCDV* p_cDV;

const int BUFF_SIZE;

std::vector<tCDV*> m_cDV;

Unit contains the following:

MC::MC():
 BUFF_SIZE(32)
{
}

MC::Test()
{
   p_cDV = new tCDV[BUFF_SIZE];

   p_cDV->intC = cc; //cc initialised elsewhere in program
   p_cDV->lngR = cr; //cr initialised elsewhere in program
   p_cDV->blnE = file.read_bool(); // file.read_bool() initialised elsewhere 
in program
   p_cDV->strC = file.read_string(); // file.read_string() initialised 
elsewhere in program

  m_cDV.push_back(p_cDV);
}

All the above works fine. My problem is that I receive memory leaks on 
program exit and the debugger points to:

    p_cDV = new tCDV[BUFF_SIZE];

I attempted to iterate through the vector: m_cDV (via the destructor of 
class MC), deleting the pointers p_cDV but to no avail. So, I scrapped the 
iteration code.

Please can someone assist me in resolving this problem.

Thanks.

Colin 


4. Force File.Delete() to Delete "in use" file - CSharp/C#

5. how to hold a console application open

Hello,

How do I hold a console application open in C#?

Thanks,
Ron

6. Opening a File using "File.Open" - CSharp/C#

7. CFile::Open doesnt open already opened MSWord File

Hi,

I am facing a problem.
I am trying to open a MS Word file using CFile::Open method. It works
fine when file is not opened. But when that MSWord file is already
opened, the CFile::Open function doesnt not open the file and return
zero.

Is it anything to do with the File Open mode i am specifying?

here is the code i am trying to execute--

        CFile f1;
	CFileException fe;
	int nFileException = 0;
	CString sFileName = "C:\\TestFile.doc";
	BOOL b1 = f1.Open(sFileName,CFile::shareDenyNone,&fe);
	if(b1)
	{
		f1.Close();
		nFileException = 0;
	}
	else
		nFileException = fe.m_cause;

Please help. I am stuck at this point.

Thanks!
Gurvinder

8. Problem opening serialized file via Open command associated with file type