gpt4 book ai didi

c# - OpenFileDialog() 锁定文件夹

转载 作者:行者123 更新时间:2023-11-30 12:18:31 29 4
gpt4 key购买 nike

我在我的 Silverlight 应用程序中使用 OpenFileDialog()。当我使用 ShowDialog() 选择一个文件时,它只是锁定该文件,直到我关闭我的应用程序。

我无法在应用程序运行时重命名或删除文件夹(浏览器中的 silverlight 应用程序)

如果我尝试选择任何其他文件夹中的任何其他文件,我可以重命名之前的文件夹。好像是在松开 handle 。

我的目标:我想在上传完成后重命名/删除文件系统中的文件夹(手动)。

我知道无法通过代码将 OpenFileDialog() 指向其他文件夹。有什么指点吗?

顺便说一句,这是 Windows 错误消息:

The action can't be completed because the folder is open in another program. Close the folder and try again.

最佳答案

我遇到了同样的问题。下面修复它

Stream fileStream = openFileDialog1.OpenFile();
if (fileStream != null)
{
...
fileStream.Close();
}

通过关闭流,我的问题就消失了...:P

关于c# - OpenFileDialog() 锁定文件夹,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/2115875/

29 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com