{
string UniqueName = string.Empty;
try
{
SPList splCurrentList = SPContext.Current.Web.Lists["MYLIST"];
bool IsNotUnique = true;
int UniqueIndex = 0;
while (IsNotUnique)
{
UniqueIndex++;
UniqueName = FileName + "_" + String.Format("{0:000}", UniqueIndex);
var listEnumeration = splCurrentList.Items.OfType
//If any matching record found, IsNotUnique returns "True", else returns 'False".
IsNotUnique = listEnumeration.Any(p => Convert.ToString(p["FILENAME"]).Trim() == UniqueName.Trim());
}
}
catch (Exception ex)
{
}
return UniqueName;
}
No comments:
Post a Comment