[Error Handling: ProjectAutomation] Any way to properly remove an incompleted project?

Hi, everyone,

I've been still working on my own analysis tool based on SDK 2.0\Sdl.SDK.ProjectAutomation.Samples.BatchAnalyze and I have just encountered another problem, hoping somebody will help me out this time againSmile

During creation of a new project, If there is no valid file to be processed (say, the only file being processed is a Word file with revision history), a project-creation process will be terminated with an error (even a sdlproject file won't have been created, yet, then).

I'm not sure that's why but the project folder created during the process containing only a source language folder cannot be deleted with newProject.Delete(); or System.IO.Directory.Delete(...);, etc.

I can think of at least one way to remove the folder by detecting a process ID holding lock on it, killing the process, and deleting the now-free folder (to be honest, I've never done that before Embarrassed) but is there any other way that's more proper?

I'll look forward to hearing from any one of you, expertsWink

Thanks in advance.

Ryota

  • Hi, everyone

    Does anybody have a clue on this question that was posted a while ago?


    I still haven't figured out how to roll back a project creation process programatically when it aborts due to a problematic file to process.
    To be more specific, I'd like to know how to delete (in a proper way) all the files and folders that have been created by the following procedure when it fails.

             private void ConvertFiles(FileBasedProject project)

            {

                #region "GetFilesForProcessing"

                ProjectFile[] files = project.GetSourceLanguageFiles();

                #endregion

     

                #region "RunConversion"

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

                {

                    if (filesIdea.Role == FileRole.Translatable)

                    {

                        Guid[] currentFileId = { filesIdea.Id };

                        AutomaticTask convertTask = project.RunAutomaticTask(currentFileId,

                                AutomaticTaskTemplateIds.ConvertToTranslatableFormat);

     

                        #region "CopyToTarget"

                        AutomaticTask copyTask = project.RunAutomaticTask(currentFileId,

                                AutomaticTaskTemplateIds.CopyToTargetLanguages);

                        #endregion

                    }

                }

                #endregion

            }

            #endregion

           

    Thank you in advance.

    Ryota