File.Copy错误 [英] File.Copy error
本文介绍了File.Copy错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
帮助!当我输入以下行时:
Help! When I type following line:
string fullAppName = System.Reflection.Assembly.GetExecutingAssembly().GetName().CodeBase;
string fullAppPath = Path.GetDirectoryName(fullAppName);
File.Copy(fullAppPath + "\\somefolder\\somefile.htm", fullAppPath + "\\someotherfolder\\somefile.htm");
我得到以下ArgumentException:
不支持URI格式.
I get following ArgumentException:
URI formats are not supported.
推荐答案
这是正确的.您不能使用URI格式.
将第一行更改为以下内容:
This is correct. You cannot use URI formats.
Change first line to the following:
string fullAppName = System.Reflection.Assembly.GetExecutingAssembly().Location;
或者,甚至更好:
Or, even better:
string fullAppName = System.Reflection.Assembly.GetEntryAssembly().Location;
以这种形式,它将起作用.
背景:URI格式要求文件系统名称以URL模式指示符"file://
"作为前缀; System.IO.File
不支持这种形式.
In this form, it will work.
Background: URI format requires prefixing file system names with URL schema indicator "file://
"; System.IO.File
does not support this form.
这篇关于File.Copy错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文