Example Code

Writing Metafile or ADS (Alternate Data Stream) Information to Files in LabVIEW

Products and Environment

This section reflects the products and operating system used to create the example.

To download NI software, including the products shown below, visit ni.com/downloads.

    Software

  • LabVIEW

Code and Documents

Attachment

Overview
This VI demonstrates modifying the meta file information on files.

 

Description
Using the OLE File Property Reader provided by Microsoft, we can access and modify properties of metafiles of files. This Knowledge Base article has more information on this.

Using the DLL provided by Microsoft, we use the property and invoke nodes to modify the properties we want to access.

 

Requirements
LabVIEW Base Development System (or compatible)

 

Steps to Implement or Execute Code
1. Place down an Automation Open function
2. Right click Automation Open, click Select ActiveX Class » Browse and search for dsofile.dll (more information detailed in the Knowledgebase article)
3. Use a Path to String function to convert the file to open to a string
4. Create an invoke node and select Open. Set Options to dsoOptionDefault
5. Create a property node and select SummaryProperties
6. Create a property node and use the reference output of SummaryProperties. Select Comments and wire in the Comments control.
7. Create an invoke node and select Close. Use the reference for OleDocument. Set SaveBeforeClose to true.
10. Close reference and connect a Simple Error


Additional Information or References
Snippet.png


**This document has been updated to meet the current required format for the NI Code Exchange.**

Example code from the Example Code Exchange in the NI Community is licensed with the MIT license.

Comments
Photon1
Member
Member
on

Fantastic for a local machine but these properties don't follow the file when transfered to another machine.

Paul_C.
Active Participant
Active Participant
on

Hello Photon1,

I just tried it on my machine and the metadata should transfer with the file.  I was able to add comments to a .txt file and I was able to see the same comments when I transferred the file to my test machine. What type of file / OS were you using?

Regards,

Paul C

ilya_ktsn
Member
Member
on

Hi Paul:

Do you know if there are any limitations, conditions, requirems to use this DSOFile DLL? For example, what files it can be used on?

I used your code to add some custom fileds to non-office file. It added the metadat fine. However, during one file copy the WIndows Explorer refused to copy the extra data (see the image). Copying MS-Office files doesn't generate the same error.

Thank you,

-Ilya.

Copy_error.jpg

bseguin
Active Participant
Active Participant
on

Hi there,

I cannot make that working in windows 7 with labview 2011.

I got no error message, and there is no metadata appearing in the windows explorer. I tried with txt file as well as zip files.

Is there a way to make that working?

Thanks