首页 > 其他分享 >Winform中使用FileStream读取文件后,继续操作提示:it is being used by anothor process

Winform中使用FileStream读取文件后,继续操作提示:it is being used by anothor process

时间:2023-03-24 15:37:59浏览次数:41  
标签:文件 used 读取 process being FileStream


场景

使用Winform搭建FTP客户端之后,读取本地某路径下的文件,然后将文件读取进行上传,再删除,在进行删除时提示:

System.IO.IOException:The process cannnot access the file...

because it is being used by another process

Winform中使用FileStream读取文件后,继续操作提示:it is being used by anothor process_上传

注:

博客:BADAO_LIUMANG_QIZHI的博客_霸道流氓气质-C#,SpringBoot,架构之路领域博主

关注公众号
霸道的程序猿
获取编程相关电子书、教程推送与免费下载。

实现

1、工具类中读取文件上传的方法

Winform中使用FileStream读取文件后,继续操作提示:it is being used by anothor process_上传_02

2、FileStream在使用后没有进行关闭,导致文件被一直占用

Winform中使用FileStream读取文件后,继续操作提示:it is being used by anothor process_上传_03

调用Close将其关闭即可

标签:文件,used,读取,process,being,FileStream
From: https://blog.51cto.com/BADAOLIUMANGQZ/6147329

相关文章