关闭excel文件上传前使用excel文件的所有进程 [英] close all process that use excel file before excel file upload

查看:172
本文介绍了关闭excel文件上传前使用excel文件的所有进程的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我收到此错误当我将文件上传到网站时,进程无法访问文件'G:\ ADMIN \Files \ aaa.xlsx',因为它正被另一个进程使用:

以下代码:



i got this error "The process cannot access the file 'G:\ADMIN\Files\aaa.xlsx' because it is being used by another process" when i upload file to website:
below code:

If FileUpload1.HasFile Then
            Dim Filename As String = Path.GetFileName(FileUpload1.PostedFile.FileName)
            
            Dim FolderPath As String = ConfigurationManager.AppSettings("FolderPath")

            Dim Filepath as string = Server.MapPath(FolderPath + Filename)

            FileUpload1.SaveAs(Filepath) // error comes at this line 

推荐答案

如果您的代码打开它,您可以关闭它,否则您可能无法关闭它。错误是说您正在尝试覆盖G驱动器上的文件,但有人将其打开。你应该找出为什么有人打开它。或者,如果它发生,也许您可​​以更改您尝试将其保存为的文件的名称。但是你会有一个不同的副本。
If it is your code that has it open you can close it otherwise you may not be able to. The error is saying that you are trying to overwrite the file on the G drive but someone has it open. You should find out why someone has it open. Or, if it happens perhaps you could change the name of the file you are trying to save it as. But then you'll have a different copy.


必须打开一些你正在通过代码访问的excel文件。您需要在使用代码之前关闭该文件。

- SG
There must be some excel file open which you are accessing through your code. You need to close that file before using in your code.
- SG


这篇关于关闭excel文件上传前使用excel文件的所有进程的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆