Please Sign up or sign in to vote. See more: VB. Hi, I have a wrote some code to delete a list of files from certain folders on my pc. I have encountered a small problem where a file is open by another process and it can not be deleted.
Does anyone know of any vb code that would help sort this problem I am having? Here is my code below: VB. Copy Code. Posted Sep am Kats Add a Solution. Top Rated Most Recent. Accept Solution Reject Solution. Posted Sep am Rakesh Meel. Well, that's not easy. For a file to be deletable, there has to be no open handles to it. You can either terminate or kill the processes helding those handles, or close the handle itself.
Be careful, the other process won't be aware of this. You might crash important applications - but could be better than killing it anyway. Still, that's your concern : So, assuming that you can determine which file is locked, you have a complete description here, how to gather all handles, how to filter the file handles and to find the file you are looking for. When you have the handle, you can close it. Posted Nov pm Member Lock Method Reference Is this page helpful? Please rate your experience Yes No.
Any additional feedback? Namespace: Microsoft. VisualBasic Assembly: Microsoft. Lock Int FileNumber Int32 Required. Any valid file number. Applies to. Lock Int32, Int Record Int64 Optional. Number of the only record or byte to lock or unlock. How are we doing? Please help us improve Stack Overflow. Take our short survey. Stack Overflow for Teams — Collaborate and share knowledge with a private group. Create a free Team What is Teams? Collectives on Stack Overflow.
Learn more. Net remove lock attribute from files in directory Ask Question. Asked 1 year, 11 months ago. Active 1 year, 11 months ago. Viewed times. All files in the displayed directory needs to be getting the Lock attribute from them - see btnConfirm to know more.
This section does not need any code - but feel free to add code if you think it could improve my program. This is what I really need help with. How can I do so?
0コメント