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


场景

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

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

because it is being used by another process

注:

博客:
https://blog.csdn.net/badao_liumang_qizhi
关注公众号
霸道的程序猿
获取编程相关电子书、教程推送与免费下载。

实现

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

调用Close将其关闭即可 

C