Thursday, October 30, 2014

Problem Retrieving SPFileVersion

I'm making a .txt to store each version of a file after I perform a certain action.


The code I'm running is simple:



write("version number: 0.1");
write
("modified : " + file.Item["Created"].ToString());
write
("modified by: " + file.Author.Name);
write
("Check in comment : " + file.CheckInComment);

foreach( SPFileVersion version in file.Versions){
if (version.VersionLabel != "0.1"){
write
("version number: "+ version.VersionLabel);
write
("modified : " + version.Created.ToLocalTime());
write
("modified by: " + version.CreatedBy.Name);
write
("Check in comment : " + version.CheckInComment);
}
}


The code does not go inside the foreach. If the code I wrote is correct, that means my files does not have any versions stored? If so, how do I do this?


I added a new .docx on a library, did check-out and check-in. Edited the file with another user, and then again a check-out and check-in. But I can't seem to get in the foreach.


Thanks!


No comments:

Post a Comment