Hello all,
I have created a .Net program with the solidworks c# api. My project takes out existing SW vault files and creates a copy of them to our local server. (Basically just caches them locally) as they update.
Everything has been working smoothly until now we just upgraded to solidworks 2021 and now the API doesn’t give any errors. But it doesn’t cache the files ether.
Here is the part of my code that grabs the files and caches them.
IEdmBatchGet pdmBatchGet = (IEdmBatchGet)vault5.CreateUtility(EdmUtility.EdmUtil_BatchGet);
EdmSelItem[] pdmSelItems = new EdmSelItem[dataTable.Rows.Count];
for (int i = 0; i < dataTable.Rows.Count; i++)
{
try
{ // CACHE File
string filepath = dataTable.Rows[i]["FilePath"].ToString();
//filepath = filepath.Replace(serverVaultRoot, localVaultRoot);
filepath = filepath.Replace(@"\\App07\PDM", localVaultRoot);
filePathCopy = filepath;
/// If the FILE CANNOT be Found, Ex to 'Catch', Log, NextFile
IEdmFile5 pdmFile;
IEdmFolder5 pdmFolder;
EdmSelItem[] pdmSelItem = new EdmSelItem[1];
pdmFile = vault5.GetFileFromPath(filepath, out pdmFolder);
//pdmSelItems[i].mlDocID = pdmFile.ID;
//pdmSelItems[i].mlProjID = pdmFolder.ID;
pdmSelItem[0].mlDocID = pdmFile.ID;
pdmSelItem[0].mlProjID = pdmFolder.ID;
//pdmBatchGet.AddSelection(vault5, ref pdmSelItems);
pdmBatchGet.AddSelection(vault5, ref pdmSelItem);
pdmBatchGet.CreateTree(0, 2048);
pdmBatchGet.GetFiles(0);
// ADD CODE FOR ERROR
// IF FILE EXISTS INSERT RECORD
string fileExists = dataTable.Rows[i]["FilePath"].ToString();
fileExists = fileExists.Replace(@"\\App07\PDM", serverVaultRoot);
if (File.Exists(fileExists))
{ …