Check if sdlxliff file is already in use

Dear all,

I would like to check whether an sdlxliff file stored on a network drive is already open in the Studio editor. For this purpose, I use the method below (source: http://stackoverflow.com/questions/9277461/how-can-i-know-file-is-already-open-or-in-use, with minor changes).

With e.g. a Word file, it works correctly and returns true if the file is open in Word. With an sdlxliff file, however, it always returns false even though the file is open in the Studio editor.

Does Studio set such kind of lock to open files? If not, is there any alternative way of checking if a particular sdlxliff file is in use by Studio?

Any hint will be much appreciated.

protected static bool IsFileLocked(FileInfo file)

{

FileStream stream = null;

try

{

stream = file.Open(FileMode.Open, FileAccess.Read, FileShare.None);

}

catch (IOException)

{

return true;

}

finally

{

if (stream != null)

stream.Close();

}

return false;

}

 

Regards,

 

Dino

Parents
  • Hi Dino,

    I don't think there is an easy way to do this.
    For one, Trados probably does not keep a lock on the file while its is opened, it probably only locks it when reading and writing to the file.

    Now, when you open a file in Trados, a folder is created in the %TEMP% directory.
    The names looks like the following:

    2xt5ry1v.eel
    svoyy4eu.5ge

    These temp folders would tell you that a certain file *was* opened during the current Trados process.
    You could also check the date of creation.
    However, there is no way to tell if the file is open right now.
    Note that these folders are erased when Trados is closed!
Reply
  • Hi Dino,

    I don't think there is an easy way to do this.
    For one, Trados probably does not keep a lock on the file while its is opened, it probably only locks it when reading and writing to the file.

    Now, when you open a file in Trados, a folder is created in the %TEMP% directory.
    The names looks like the following:

    2xt5ry1v.eel
    svoyy4eu.5ge

    These temp folders would tell you that a certain file *was* opened during the current Trados process.
    You could also check the date of creation.
    However, there is no way to tell if the file is open right now.
    Note that these folders are erased when Trados is closed!
Children