4 Replies Latest reply on Jan 14, 2019 5:30 PM by Justin Hunt

    EPDM BatchGet -> Get Latest Version for VB.NET 4.5

    Ethan Kinney

      Hi All,


      I was having trouble trying to do a batchget in EPDM to get the latest version of all files in a directory and I finally figured it out.


      Here is the code I was using:



                  Dim Vault As New EdmVault5
                  Vault.LoginAuto("Engineering", 0)
                  Dim SubFolder As String = Vault.RootFolderPath & "\DirectoryToRefresh"
                  Dim GetDirectory() As EdmSelItem = Nothing
                  ReDim GetDirectory(0)
                  GetDirectory(0).mlDocID = 0
                  GetDirectory(0).mlProjID = Vault.GetFolderFromPath(SubFolder).ID
                  Dim bg As IEdmBatchGet
                  bg = Vault.CreateUtility(EdmUtility.EdmUtil_BatchGet)
                  bg.AddSelection(Vault, GetDirectory)
                  bg.CreateTree(0, EdmGetCmdFlags.Egcf_Nothing)
                  bg.GetFiles(0, Nothing)
              Catch ex As Runtime.InteropServices.COMException
                  MessageBox.Show("HRESULT = 0x" + ex.ErrorCode.ToString("X") + vbCrLf + ex.Message)
              Catch ex As Exception
              End Try


      For the longest time i was getting an "E_INVALIDARG" on the line "bg.AddSelection".

      Finally I stumbled accross this page in the API Help Documentation:



      If you are developing in Visual Studio like I was and have a reference set to interop.edmLib you have to do the following:

      Go to "My Project" > "References" > Click on PDMWorks Enterprise 20xx Type Library > and set the "Embed Interop Types" to False


      Note: This is vaild if you are programming in 4.0 or 4.5! (I was programming in 4.5)


      After I changed this value, then bingo, worked like a charm.


      Hopefully this will help someone else out!




        • Re: EPDM BatchGet -> Get Latest Version for VB.NET 4.5
          Jason Clarke


          Not to diminsh you effort, I'm sure the code will come in handy as reference to others, but I was curious of this was for an external add-in? otherwise, for internal things you could use Dispatch  to achieve the same thing without any API coding.

          • Re: EPDM BatchGet -> Get Latest Version for VB.NET 4.5
            Matthew aDAMS

            Thank you for posting this!  I have been fighting this for two days.  Felt a little silly when I read this!

            • Re: EPDM BatchGet -> Get Latest Version for VB.NET 4.5
              Justin Hunt

              Hi, I know I am little late to the party, but I thought I would add this as a reference. Here is how I did it (C#):


              public static bool Batch_Get(string[] files, int Handle, IEdmFolder5 folder)




                              //create batchGet object

                              IEdmVault7 vault7 = vault as IEdmVault7;

                              IEdmBatchGet batchGetter;

                              batchGetter = (IEdmBatchGet)vault7.CreateUtility(EdmUtility.EdmUtil_BatchGet);


                              //create the selection list

                              var list = new List<EdmSelItem>();

                              var selectedFile = default(EdmSelItem);


                              foreach (var file in files)


                                  var ppoRetParentFolder = default(IEdmFolder5);

                                  var aFile = vault.GetFileFromPath(file, out ppoRetParentFolder);

                                  selectedFile = new EdmSelItem();

                                  IEdmPos5 aPos = aFile.GetFirstFolderPosition();

                                  IEdmFolder5 aFolder = aFile.GetNextFolder(aPos);

                                  selectedFile.mlDocID = aFile.ID;

                                  selectedFile.mlProjID = aFolder.ID;




                              //Do not change this - the array must init as null

                              EdmSelItem[] ppoSelection = null;

                              ppoSelection = list.ToArray();

                              batchGetter.AddSelection((EdmVault5)vault, ppoSelection);



                              //Create tree

                              batchGetter.CreateTree(Handle, (int)EdmGetCmdFlags.Egcf_Lock);




                              return true;


                          catch (Exception ex)



                              return false;