Project Automation API: Filebased

We have come along a problem with the project automation API. The problem is that we cannot remove SDLXLIFF files from a Studio project carrying out the code below. If we run the code, there is no error message, it runs through nicely. However, in the end, the removed file still exists in the project.

 

Can you see if there is anything obviously wrong with our code or is this simply a problem in the API? Are we missing something here?

 

Many thanks for looking at this!

Cheers

Tom

 

                ProjectFile[] targetFiles = studioProject.GetTargetLanguageFiles();

              

                for (int i = 0; i < targetFiles.Length; i++)

                {

                    if (targetFiles[i] != null)

                    {

                        if (targetFiles[i].Name == strFileName_ToRemove)

                        {

                            Guid fileId = targetFiles[i].Id;

 

                            studioProject.RemoveBilingualReferenceFile(fileId);

 

                            isSdlxliffRemoved = true;

                           

                            studioProject.Save();

                        }

                    }

                }

 

We also tried this VB.net code - same behaviour, though (i.e. code runs without errors, the file that is removed is still in the project after saving the project):

Public Function RemoveFiles ()
        Dim NewProjInfo As New ProjectInfo
        Dim NewProj As FileBasedProject
        Dim WorkingFiles() As ProjectFile
        Dim GUID As System.Guid
        NewProj = New FileBasedProject("C:\Test\Test.sdlproj")
        WorkingFiles = New ProjectFile() {}
        WorkingFiles = NewProj.GetTargetLanguageFiles()
        For i = 0 To WorkingFiles.Count -1
            GUID = WorkingFiles(i).Id
            NewProj.RemoveBilingualReferenceFile(GUID)
            NewProj.Save()
        Next
End Function

Parents Reply Children
No Data