简体   繁体   English

为什么文件夹在Windows XP和Windows Server 2003上被锁定?

[英]Why folders are locked on Windows XP and Windows Server 2003?

There is a problem that I can't safely remove a USB disk on XP and 2003 Server, because my application holds it. 我无法安全地删除XP和2003 Server上的USB磁盘,因为我的应用程序保存了它。 There is a folder on USB, in which some files are held. USB上有一个文件夹,其中保存了一些文件。 I need to copy those files from USB to some destination folder on disk C:. 我需要将这些文件从USB复制到磁盘C:上的某个目标文件夹中。 After this is done I'm trying to safely remove disk and cannot do this because my application uses it. 完成此操作后,我试图安全删除磁盘,但无法执行此操作,因为我的应用程序使用了它。 Actually it holds the folder on USB where files that has to be copied are situated. 实际上,它将USB文件夹保存在必须复制文件所在的位置。 This is happening only on XP and 2003 server, but not in Windows 7. What could it be? 这仅在XP和2003服务器上发生,而在Windows 7中则没有。 I use methods from File class such as Copy , Exists , SetAttributes and methods from Path class. 我使用File类的方法,例如CopyExistsSetAttributesPath类的方法。 Thanks in advance. 提前致谢。

Folders are shared objects, just like files. 文件夹是共享对象,就像文件一样。 You cannot remove a folder, or the drive on which it resides, until all handles on the folder are closed. 在关闭文件夹上的所有句柄之前,您无法删除文件夹或其所在的驱动器。

They tend to be hard to identify. 它们往往很难识别。 Most pernicious are the lock created when an app makes the folder its default working directory, equivalent of the .NET Environment.CurrentDirectory property. 最有害的是当应用程序将文件夹设置为默认工作目录(相当于.NET Environment.CurrentDirectory属性)时创建的锁。 Forgetting OpenFileDialog.RestoreDirectory is a standard trap. 忘记OpenFileDialog.RestoreDirectory是一个标准陷阱。 And when an app monitors the directory for changes, equivalent of the .NET FileSystemWatcher class. 当应用监视目录更改时,等效于.NET FileSystemWatcher类。 Just plain hard to see them. 只是很难看到他们。 Windows 7 and up make it a bit easier to deal with by allowing the volume to be ejected anyway. Windows 7及更高版本允许以任何方式弹出该卷,从而使其处理起来更加容易。 Follow-up at superuser.com, there are no doubt utilities around that make this more visible. 在superuser.com上进行了后续跟踪,毫无疑问,实用程序可以使此操作更加明显。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 审核Windows Server 2003文件夹 - Auditing Windows Server 2003 folders RegisterHotkey 仅适用于 WIndows 7,不适用于 XP、服务器 2003 - RegisterHotkey only working in WIndows 7, not in XP, server 2003 Windows XP / Server 2003 / VS 2010上的CefSharp - CefSharp on Windows XP / Server 2003 / VS 2010 通知图标可以在Windows XP中正常工作,但不能在Windows Server 2003中正常工作 - Notify icon working fine in windows XP but not in windows server 2003 应用程序在Windows XP下运行,但不在Server 2003 R2下运行 - Application runs under windows xp but not under server 2003 r2 如何在Windows Server 2003和Windows XP中延迟创建的服务? - How can I delay my created service in Windows Server 2003 & Windows XP? 为什么System.Drawing.Image.GetPropertyItem在Windows XP / 2003上的行为与Windows 7相比有所不同 - Why does System.Drawing.Image.GetPropertyItem behave differently on Windows XP / 2003 compared to Windows 7 windows 服务在 windows 7 上工作,但不在 windows 服务器 2003 上 - windows service working on windows 7 but not on windows server 2003 无法在某些Windows XP / Server 2003计算机上建立HTTPS连接 - Can't establish HTTPS connections on some Windows XP/Server 2003 machines 在Windows XP中获取最近的文件夹和最近的文件 - Getting Recent folders and Recent files in Windows XP
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM