A while back, I wrote an article on the extra steps you need to do on download in order to avoid the “edited out of turn” status . Unfortunately, I neglected to provide the extra steps you need to do on upload.
When adding or checking in a file from the working folder, you should set the file to read-only. This makes the file less likely to get updated by accident. It also insures the correct file status in Vault Explorer.
You should also set the create date on the local file so that it matches the CreateDate value from the File object returned from Vault. This part is a bit confusing because File.CreateDate is the datetime that the version was created (aka. the check-in time). So your file on disk will have a create date larger than the last modified date.
Those are the two basic things to set: read-only and create date. They are same two steps are used for download. Here is some example code:
File file = m_svcMgr.DocumentService.AddFile(
folder.Id, filename, comment,
null, null, FileClassification.None, false, byteArray);
FileAttributes baseAttr = System.IO.File.GetAttributes(localpath);
FileAttributes rwAttr = baseAttr & ~FileAttributes.ReadOnly;
FileAttributes readOnlyAttr = baseAttr FileAttributes.ReadOnly;
// clear the read-only bit if it is there
// set create time to match Vault
// set the read-only bit
Dim file As File = m_svcMgr.DocumentService.AddFile( _
folder.Id, filename, comment, _
Nothing, Nothing, _
FileClassification.None, False, byteArray)
Dim baseAttr As FileAttributes = _
Dim rwAttr As FileAttributes = _
baseAttr And Not FileAttributes.[ReadOnly]
Dim readOnlyAttr As FileAttributes = _
baseAttr Or FileAttributes.[ReadOnly]
' clear the read-only bit if it is there
' set create time to match Vault
' set the read-only bit
If you are uploading from a location other than the working folder, you don’t need to worry about these steps. The Vault status will be empty since it won’t find a match on the local file system. If you are checking in and keeping the file checked out, you can also ignore these steps.