如何强制写入/删除另一个用户远程打开的文件?

发布于 2024-11-05 02:54:53 字数 355 浏览 0 评论 0原文

我正在编写一个过程,在文件共享中生成一些报告,其他用户可以打开这些报告进行阅读(例如 csv 文件)。如果在向其中添加内容时打开了一份报告(在 Excel 中),我会收到一条错误“该进程无法访问文件‘[...]’,因为它正在被另一个进程使用”。

作为替代方案,我可以阻止其他用户从输出位置访问这些报告,并在他们有权访问的目录上安排副本,但该副本将具有相同的结果,因为文件副本仍然不可能当他们在该目录中打开文件时。

我无法关闭拥有该文件句柄的进程,因为它位于任何另一台计算机上。该文件甚至不在运行该进程的计算机上,而是在远程文件共享上。

这似乎是一种常见情况,但我能弄清楚如何复制/写入文件的唯一方法是等到其他用户关闭它,这在我的情况下是不可接受的。

I'm writing a process that produces some reports in a file share, which other users can open for reading (csv files, for example). If one has a report opened (in excel) when i'm appending contents to it, i receive an error "The process cannot access the file '[...]' because it is being used by another process".

As an alternative, I can block other users from accessing these reports from the output location, and schedule a copy on a directory in which they'll have access, but that copy would have the same result, since the file copy is still not possible when they have the file opened in that directory.

I cannot close the process that has an handle on the file, since it's on any another computer. The file is not even on the computer running the process, but a remote file share.

That seems to be a common situation, but the only way I can figure out how to manage to have the file copied/written is to wait until it's closed by the other user, which is not acceptable in my situation.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

天赋异禀 2024-11-12 02:54:53

可能不是一个选择,但是您可以通过内部网络服务器提供报告吗?这将防止可怕的“文件正在使用”问题。

Probably not an option, but can you serve out the reports via an internal web server? That would prevent the dreaded "file in use" problem.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文