关于WebClient.DownloadFile打开远程excel文件的问题 [英] question about WebClient.DownloadFile with remote excel file opened
问题描述
你好
我想问一个问题
i'd like to ask a question
我的代码就是那样
my code is like that
System.Net.WebClient webClient = new System.Net.WebClient();
webClient.UseDefaultCredentials = true;
webClient.DownloadFile(remote, local);
我发现,如果远程文件是excel文件且由excel打开,则错误"无法访问远程,因为它被另一个过程使用
I found that, if the remote file is an excel file and it is open by excel, the error "cannot access remote becuase it is used
显示
请问,是否有解决方案,即使excel文件打开,我们也可以从远程下载excel文件?
May i ask, is there a solution, we can download excel file from remote even the excel file is opened?
非常感谢你
最好的问候
推荐答案
我不认为Excel会允许您更改磁盘上的活动文件。但是您可以截取异常并选择另一个文件名( local 变量),例如"MyFile(2).xlsx"而不是"MyFile.xlsx"。或者您可以
要求用户确认情况并选择其他名称。
I do not think that Excel will allow you to alter the active file on the disk. But you can intercept the exception and choose another file name (local variable), for example "MyFile (2).xlsx" instead of "MyFile.xlsx". Or you can ask the user to confirm the situation and select another name.
这篇关于关于WebClient.DownloadFile打开远程excel文件的问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!