How to obtain the ID of a newly uploaded document using web services (c#, .net)? Is the following the best way to obtain Doc ID?
private string sGetID(string sURL, string sListGUID, string sFileName)
{
string sUser = ConfigurationManager.AppSettings("User");
string sPwd = ConfigurationManager.AppSettings("Pwd");
string sDomain = ConfigurationManager.AppSettings("Domain");
System.Net.NetworkCredential netAccess = new System.Net.NetworkCredential(sUser, sPwd, sDomain);
SPLists.Lists L = new SPLists.Lists();
L.Credentials = netAccess;
L.Url = sURL;
XmlDocument xmldoc = new XmlDocument();
XmlNode query = xmldoc.CreateNode(XmlNodeType.Element, "Query", "");
query.InnerXml = "<OrderBy><FieldRef Name='Modified' " + "Ascending='False'></FieldRef></OrderBy>\"";
try {
XmlNode caml = L.GetListItems(sListGUID, null, query, null, "1", null);
string id = caml.ChildNodes(1).ChildNodes(1).Attributes("ows_ID").Value;
return id;
} catch (Exception ex) {
return ex.Message;
}
}