Some time it is required just to know the what was the last version of the file saved in the version enabled document library.
public Double getLastVersion(string flname, bool tt)
{
string doclibname = ConfigurationManager.AppSettings["doclibname"].ToString();
Double ver = 0;
//get the latest version
using (SPSite objSite = SPContext.Current.Site)
{
using (SPWeb objWeb = objSite.OpenWeb())
{
SPFolder mylibrary = objWeb.Folders[doclibname];
foreach (SPFile file in mylibrary.Files)
{
if (file.Name.ToString() == flname+ ".doc")
{
ver = System.Convert.ToDouble(file.UIVersionLabel);
Break;
}
}
return ver;
}
}
}
Thanks
Sanjay Tiwari
Dallas, Texas
Wednesday, April 28, 2010
How to get the latest version lable of a file
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment