Home > Software engineering >  MFC failed to delete file
MFC failed to delete file

Time:10-07

MFC deletefile not delete files, Movefile also move fails, Getlasterror returns 32 - & gt; Process cannot access the file because another process is using this file. Consult everybody a great god how to delete files? Beginners MFC, there are a lot of things is not clear, so it is better for example, thank you.

CodePudding user response:

Indicates that the file is occupied by other processes, cannot be delete, and move is very normal,
When using the file process closed, can delete and move,

CodePudding user response:

reference 1st floor BeanJoy response:
indicates the file is occupied by other processes, cannot be delete, and move is very normal,
When using the file close process, can delete and move,

How can I close this process?

CodePudding user response:

refer to the second floor Carl_Lei_1 response:
Quote: refer to 1st floor BeanJoy response:

Indicates that the file is occupied by other processes, cannot be delete, and move is very normal,
When using the file close process, can delete and move,

How can I close this process?


Kill the process, some close button at top right corner,

CodePudding user response:

http://www.nirsoft.net/utils/opened_files_view.html

CodePudding user response:

Open the file, it needs to close

CodePudding user response:

My program consists of three parts -- Fromfile import images, and then through the thread of image processing, with deletefile finally removed the original, but now the problem is not delete files and GetLastError returns 32. Seek the solution,
 m_pSelectedImage=Bitmap: : FromFile (filePath. AllocSysString ())//import images, filePath as the path to the file; 
.
M_hThreadTools=CreateThread (NULL,
0,
RunImageToolsThread,
This,
0,
& M_dwThreadID);//create a thread
.
The DeleteFile (filePath);//delete files

CodePudding user response:

First of all, which process is confirmed in take up the documents?

Turn off your application, use resource managers try to delete files, if can be deleted at this time, your program opens the file, not closing DeleteFile failures,

CodePudding user response:

FromFile takes up the file, so I can't delete,

Have you release the Dispose?

CodePudding user response:

See if there is where you create a thread to use this file,

CodePudding user response:

refer to the eighth floor boylafong response:
FromFile takes up the file, so I can't delete,

Have you release the Dispose?

Could you tell me how? After the thread to run automatically quit,

CodePudding user response:

references 9 f shiyanzi response:
see if there is where you create a thread to use this file,

Are the forms of pointer call
For example, to get the image of RGB values
 
LpParam CImageView * pView=(CImageView *);//get the current view
PView - & gt; M_pSelectedImage - & gt; GetPixel (x, y, & amp; Color);

CodePudding user response:

references to the tenth floor Carl_Lei_1 response:
Quote: refer to the eighth floor boylafong response:

FromFile takes up the file, so I can't delete,

Have you release the Dispose?

Could you tell me how? Threads run automatically after the exit,


What time do you need not when to exit the
With the help of m_pSelectedImage thread

CodePudding user response:

The
refer to 12 floor boylafong reply:
Quote: reference to the tenth floor Carl_Lei_1 response:

Quote: refer to the eighth floor boylafong response:

FromFile takes up the file, so I can't delete,

Have you release the Dispose?

Could you tell me how? Threads run automatically after the exit,


What time do you need not when to exit the
M_pSelectedImage thread USES

Used to, like I said in the 11th floor

CodePudding user response:

reference 13 floor Carl_Lei_1 reply:
Quote: refer to 12 floor boylafong reply:

The
Quote: reference to the tenth floor Carl_Lei_1 response:

Quote: refer to the eighth floor boylafong response:

FromFile takes up the file, so I can't delete,

Have you release the Dispose?

Could you tell me how? Threads run automatically after the exit,


What time do you need not when to exit the
M_pSelectedImage thread USES

Used to, like I said on the 11 floor



Since your pSelectedImage thread was used, so you delete affirmation again after the calling thread error


To Dispose FromFile is complete, just like new and delete ah, problems have been found, it's just your logic is not correct,

CodePudding user response:

Is you open the file is not closed, closed with sleep a few milliseconds, then delete

CodePudding user response:

On the 14th floor boylafong
reference response:
since your pSelectedImage thread was used, then you delete affirmation again after the calling thread error


To Dispose FromFile is complete, just like new and delete ah, problems have been found, it's just your logic is not correct,

Error C2039: "Dispose", not "Gdiplus: : Bitmap" members of the

CodePudding user response:

Using STD: : unique_ptr

A member variable unique_ptr & lt; Bitmap> M_bitmap;

Loading picture m_bitmap. The reset (Bitmap: : FromFile (L "XXX"));

When you want to delete the file, m_bitmap. Reset (); DeleteFile ();

CodePudding user response:

Your thread hasn't quit,

CodePudding user response:

reference 16 floor Carl_Lei_1 response:
Quote: refer to the 14 floor boylafong response:



Since your pSelectedImage thread was used, so you delete affirmation again after the calling thread error


nullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnull
  • Related