locked
DSO - CustomProperty - Check if exsists RRS feed

  • Question

  • I have the following code to add a custom property "DCN" to files in a directory & need to determine wif this value exists & if so to skip the file:

     

    1 Dim sDir As DirectoryInfo = New DirectoryInfo(My.Settings.PDMDir)  
    2         sDir.GetDirectories()  
    3         For Each f As FileInfo In sDir.GetFiles  
    4             dso = New DSOFile.OleDocumentProperties  
    5             dso.Open(f.FullName)  
    6             dso.CustomProperties.Add("DCN", DCNNo + i)  
    7             dso.Save()  
    8             i = i + 1  
    9         Next 


    I cannot find a method to handle this.

    Thanks,

    Vwalla 

    Monday, August 4, 2008 2:56 PM

Answers

  • Hi Vwalla,

    Try the following code snippet. Modify it based on your requirement. Hope this helps.

                 Dim sFilename As String 
            Dim DSO = New DSOFile.OleDocumentProperties 
            DSO.Open(sFileName:="C:\tmp.pdf"
            For i As Integer = 0 To DSO.CustomProperties.Count - 1 
                Console.WriteLine(DSO.CustomProperties.Item(i).Name & vbCrLf & _ 
                DSO.CustomProperties.Item(i).Value) 
            Next 
            DSO.Close() 
            DSO = Nothing 


    Best regards,
    Riquel

    Please remember to mark the replies as answers if they help and unmark them if they provide no help.
    Wednesday, August 6, 2008 9:02 AM
    Moderator

All replies

  • Hi Vwalla,

    Try the following code snippet. Modify it based on your requirement. Hope this helps.

                 Dim sFilename As String 
            Dim DSO = New DSOFile.OleDocumentProperties 
            DSO.Open(sFileName:="C:\tmp.pdf"
            For i As Integer = 0 To DSO.CustomProperties.Count - 1 
                Console.WriteLine(DSO.CustomProperties.Item(i).Name & vbCrLf & _ 
                DSO.CustomProperties.Item(i).Value) 
            Next 
            DSO.Close() 
            DSO = Nothing 


    Best regards,
    Riquel

    Please remember to mark the replies as answers if they help and unmark them if they provide no help.
    Wednesday, August 6, 2008 9:02 AM
    Moderator
  • Thanks for the reply, & sorry for delay in mine.  I am not getting emails alerting me to post replies :(

    Anyways...I added a line of code above the statement with errors of On Error Resume Next and it solved the problem.

    Thanks!

    Vareck
    Friday, August 8, 2008 12:54 AM