且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

如何删除其他进程使用的文件和文件夹?

更新时间:2023-09-25 21:28:16





我们的应用程序如何访问文件,当我们尝试打开文件时,它打开一个ptr(指针),该文件对于该文件是唯一的,因此如果文件没有共享系统将不允许指向其他进程。



如何在C中使用文件: http ://www.codingunit.com/c-tutorial-file-io-using-text -files [ ^ ]



&在C#



http://www.dotnetperls.com/file [ ^ ]



因此,如果你想同时访问文件,你需要共享文件,但就删除而言,它不会解决问题所以你需要首先杀死这些进程然后你就可以删除它。
Hi,

How our application access a file, when we try to open the file it open a ptr( Pointer) which unique for that file so if the file is no shared system will not allow to point other process to it.

How to Use Files in C : http://www.codingunit.com/c-tutorial-file-io-using-text-files[^]

& in C#

http://www.dotnetperls.com/file[^]

So if you want to access files in same time you need to share file but in terms of delete it wont solve the problem so you need to kill those process first then you will be able to delete it.


你不应该解决那个'问题'。删除另一个文件时删除文件并不好。解决方法是终止使用该文件然后删除文件本身的过程(无论如何不是一个好的行为)。

为什么不简单地通知用户?
You shouldn't solve that 'problem'. It is not nice to delete a file while it is used by another. A workaround would be terminating the process that uses the file and then deleting the file itself (anyway not a nice behaviour).
Why don't you simply inform the user about?


逻辑上它只在

时可用1.可访问文件夹/文件关闭或

2.由TaskManager访问文件/文件夹的进程结束

3.可访问文件/文件夹从resp进程中释放。
Logically its possible only when
1. Accessible folder/file is closed OR
2. Process end tasked for accessing Files/Folders by TaskManager
3. Accessible file/Folder is released from resp process.