我正在尝试在Xamarin中使用相机,并且有一个获得如下唯一路径的方法
private string GetUniquePath(string path, string name)
{
string ext = Path.GetExtension(name);
if (ext == string.Empty)
ext = ".jpg";
name = Path.GetFileNameWithoutExtension(name);
string newName = name + ext;
int i=1;
while (File.Exists(Path.Combine(path,newName)))
newName = name + "_" + (i++) + ext;
return Path.Combine(path, newName);
}
我收到错误 - while(File.Exists(Path.Combine(path,newName)))
错误不会超载方法' Exists'需要1个参数。
然而,这与我到处看到的格式相同。有什么建议吗?
答案 0 :(得分:0)
错误CS1501:方法
Exists' takes
1'没有重载参数
我认为它正在拾取Java.IO.File.Exists
,它不会带任何参数。
尝试完全限定命名空间:
while (System.IO.File.Exists(System.IO.Path.Combine(path,newName)))
newName = name + "_" + (i++) + ext;