Quantcast
Channel: SharePoint 2010 - Development and Programming forum
Viewing all articles
Browse latest Browse all 11571

How do i programmatically get the current version of a file?

$
0
0

I asked this same question in the SP2013 forum and I haven't been able to determine the solution. So I posting this here, to maybe get more eyes on this issue. 

...I am basically trying to programmatically get the current version of a document in a library, then determine if its a major or minor version, in code. I have tried doing this, to get the current version but I keep getting an empty string returned.

var versions = item.File.Versions;
string currentVersion = string.Empty;
foreach (SPListItemVersion version in item.Versions)
{
	DateTime lastMod = version.Created;

	foreach (SPFileVersion fileVersion in versions)
	{
		if (fileVersion.IsCurrentVersion == true)
		{
			currentVersion = fileVersion.ToString();                        
		}
	}
}

Does anyone know what am doing wrong, and how to get this resolved? I really appreciate the help. Thanks


Viewing all articles
Browse latest Browse all 11571

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>