File Properties - Reading from a draft file that user has open

Phenom
Phenom

I have a macro that reads file properties from all draft files in a folder and lists files those containing a match to a user-defined value.

The problem I have is that if a user has the draft file open the macro stops.

I have tried setting the file to open read-only, but it doesn't make any difference - True or False gives the same result.

objPropertySets.Open(strFilename,True)

I can only assume this is not the correct format.

If not, how should I do it ?

HP Z420 16GB RAM
Quadro K4000
ST7 MP10 on Windows 7 Pro 64.
2 REPLIES

Re: File Properties - Reading from a draft file that user has open

Legend
Legend

Hi Beachcomber,

I've ran into this on a couple occasions.  There's a bunch of threads here about using SolidEdgeFileProperties.dll and this problem.  IMO it is an error in the library "read only" should be read enabled, but apparently read protected is expected behavior.  I'm assuming it's concurrency issues they are worried about.  Here's a thread I started about it that also shows how windows explorer cannot access file properties of an open file.

 

https://community.plm.automation.siemens.com/t5/Solid-Edge-Developer-Forum/Document-properties-unava...

 

I wraped the open call in a try/catch and just return, as far as I know 99.999% of the execptions are what you are talking about.

      private string GetPartProperties(string path)
      {
         if( !new System.IO.FileInfo(path).Exists )
         {
            return "Path does not exist";
         }
         PropertySets filePropertySets;
         Properties fileProperties;
         filePropertySets = new PropertySetsClass();
         try
         {
            filePropertySets.Open(path, System.IO.FileShare.ReadWrite);
         }
         catch (System.Runtime.InteropServices.COMException e)
         {
            return e.Message + e.ToString();
         }

In a more recent project I'm using Newell's SolidEdgeCommunity.Reader lib and from what I can tell it doesn't care if the file is open in SE.  It's not using any SE libs though, it's parsing the raw stores and streams data in the compound file.  Only problem I've ran into so far is getting data from a family of assemblies file, otherwise it's working great for me.  It's available on NuGet too.

 

https://github.com/SolidEdgeCommunity/SolidEdge.Community.Reader

 

  Ironicaly one of the features of a compound file is able to read and write different parts of it at the same time.

 

Hope something in there helps.


Those who know me question the assigned user rank.

Re: File Properties - Reading from a draft file that user has open

Phenom
Phenom

@bnemec

Thanks for your input.

I'd seen the post you referred to but decided it wasn't the way for me to go in this instance.

The macro isn't something that will be used that often - it just allows us to get a list of drawings that should be called up on a GA drawing. We can then check that all appropriate models have been added to the GA. (they don't always get done, or the GA model might not even exist)

I have got round the problem by checking the error number, and then skipping if the error occurred.

A message box informs the user which file(s) can't be opened, so those can be checked later.

HP Z420 16GB RAM
Quadro K4000
ST7 MP10 on Windows 7 Pro 64.