In one of my scripts, I need to delete a file that could be used at that time. I know that I cannot delete a file that is used until it is no longer there, but I also know that I can mark the file for deletion by the operating system (Windows XP). How can I do this in Python?
import win32file import win32api win32file.MoveFileEx("/path/to/lockedfile.ext", None , win32file.MOVEFILE_DELAY_UNTIL_REBOOT)
... and another version that is independent of the pywin32 binaries.
import ctypes MOVEFILE_DELAY_UNTIL_REBOOT = 4 ctypes.windll.kernel32.MoveFileExA("/path/to/lockedfile.ext", None, MOVEFILE_DELAY_UNTIL_REBOOT)
MoveFileEx:
MoveFileEx
dwFlags MOVEFILE_DELAY_UNTIL_REBOOT, lpNewFileName - NULL, MoveFileEx lpExistingFileName, . lpExistingFileName , , .
Source: https://habr.com/ru/post/1770214/More articles:Receive movie notifications in UIWebView - iphoneWhy does $ wpdb-> insert_id and mysql_insert_id () return with an extra "1" at the end? - phpMongoDB performance based on document size - performanceRecommendations for providing dynamic widget content for third-party sites? - javascriptHow to write header files for devices - cHow to install "Windows Phone Developer Tools RTW" without installing Visual Studio? - visual-studioASP.NET Response.TransmitFile Error on first boot - c #Using substring - after searching for text in XPath query - substringAre .net delegating real objects? - c #UI Usability Book for Developers - user-interfaceAll Articles