Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- private void button1_Click(object sender, EventArgs e)
- {
- SolidEdgeFileProperties.PropertySets propertySets = null;
- SolidEdgeFileProperties.Properties properties = null;
- SolidEdgeFileProperties.Property property = null;
- string format1 = "[{0}]";
- string format2 = "{0} = {1}";
- try
- {
- // Create new instance of the PropertySets object
- propertySets = new SolidEdgeFileProperties.PropertySets();
- // Open a file
- propertySets.Open(Directory.GetCurrentDirectory() + @"\327935-01.par", true);
- // Example: Loop through all properties
- // Note that indexes are zero based
- for (int i = 0; i < propertySets.Count; i++)
- {
- properties = (SolidEdgeFileProperties.Properties)propertySets[i];
- // Note that indexes are zero based
- for (int j = 0; j < properties.Count; j++)
- {
- property = (SolidEdgeFileProperties.Property)properties[j];
- try
- {
- Console.WriteLine(
- string.Format(
- format2, property.Name, property.Value));
- }
- catch
- {
- Console.WriteLine(
- string.Format(
- format2, property.Name, "ERROR"));
- }
- }
- }
- // Get a reference to the SummaryInformation properties
- properties = (SolidEdgeFileProperties.Properties)
- propertySets["SummaryInformation"];
- // Get a reference to the Title property by name
- property = (SolidEdgeFileProperties.Property)
- properties["Title"];
- }
- catch (System.Exception ex)
- {
- Console.WriteLine(ex.Message);
- }
- finally
- {
- if (property != null)
- {
- Marshal.ReleaseComObject(property);
- property = null;
- }
- if (properties != null)
- {
- Marshal.ReleaseComObject(properties);
- properties = null;
- }
- if (propertySets != null)
- {
- propertySets.Close();
- Marshal.ReleaseComObject(propertySets);
- propertySets = null;
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement