
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
Hello,
I am trying to checkin local files that are not in the Vault yet. I'm using the ocde below but get an error and don't know what to do?
I am woriking in Inventor 2016/2017.
I found the code below online and there was no mentioning of problems.
I have a treelist with local files not in the vault yet. The user selects the file he wants to check in.
private void btnCheckIn_Click(object sender, EventArgs e)
{
IEnumerable<Autodesk.DataManagement.Client.Framework.Vault.Currency.Entities.Folder> thevaultfolders = _vaultConnection.FolderManager.GetChildFolders(_vaultConnection.FolderManager.RootFolder, true, false);
List<TreeListNode> chknodes = treeListUncheckFiles.GetAllCheckedNodes();
foreach (TreeListNode treeListNode in chknodes)
{
string flnam = treeListNode.GetDisplayText(0);
if (!System.IO.File.Exists(flnam)) continue;
string fldrnaam = Path.GetDirectoryName(flnam);
fldrnaam = GetDirnaam(fldrnaam);
Autodesk.DataManagement.Client.Framework.Vault.Currency.Entities.Folder fldr = thevaultfolders.FirstOrDefault(n => n.FullName.Equals(fldrnaam));
if (fldr == null) continue;
Autodesk.DataManagement.Client.Framework.Vault.Currency.Entities.FileIteration fileIteration;
using (Stream sr = new FileStream(flnam, FileMode.Open, FileAccess.Read))
{
fileIteration = _vaultConnection.FileManager.AddFile(fldr, fldrnaam, "Added by CreateForce",
DateTime.Now, null, null, FileClassification.DesignDocument, false, sr);
//// THIS IS THE LINE INVENTOR CRASHES. SOMETIMES WITHOUT A WARNING.
/// AND SOMETIMES WITH THE MESSAGE:
File Cannot be Added. 'test.iam" cannot be added due to vault restrictions.
Restriction: You must add design files to the vault through the appropriate application to maintain correct relationship data.
}
_vaultConnection.FileManager.CheckinFile(fileIteration, "Added by CreateForce", false, null, null, false,
flnam, FileClassification.None, false, new FilePathAbsolute(fldrnaam));
treeListUncheckFiles.Nodes.Remove(treeListNode);
}
}
How can I get this to work ?
Solved! Go to Solution.