cancel
Showing results for 
Search instead for 
Did you mean: 

VersionInfo.LegalCopyright

han
Contributor

VersionInfo.LegalCopyright

How could I check if the LegalCopyright is present for a file with out getting a error for those that doesn't have the LegalCopyright properties set.



Think I tried them all  (IsSupported, IsNull, IsNothing, IsEmpty, Len > 0 ...)



---Code---

Copyright = aqFileSystem.GetFileInfo(file).VersionInfo.LegalCopyright

>>>If Copyright.Exists Then


    Log.Message ("Copyright for the file "+ file + " is ...")

        Else

    Log.Warning ("Copyright for the file "+ file + " is missing!")


end if

1 REPLY 1

RE: VersionInfo.LegalCopyright


Hi Hakan,





LegalCopyright is an array of strings. The needed value is stored in the first element of the LegalCopyright array (LegalCopyright(0)). The following script demonstrates how to verify copyright for a file:







Sub Main

  Dim file, fileObj, Copyright   





  file = "<full name>"

  Set fileObj = aqFileSystem.GetFileInfo(file)

  Copyright = getCopyright(fileObj)

  If Len(Copyright) > 0 Then

    Log.Message ("Copyright for the file "+ file + " is " + Copyright)

  Else

    Log.Warning ("Copyright for the file "+ file + " is missing!")

  End If

End Sub





Function getCopyright(fileObj)

  Dim VerInfo

  If fileObj.VersionInfo Is Nothing Then

    Log.Warning "No version info in file."

    getCopyright = ""

    Exit Function

  End If

  Set VerInfo = fileObj.VersionInfo

  If Len(VerInfo.LegalCopyright(0)) = 0 Then

    Log.Warning "No legal copyright in version info field."

    getCopyright = ""

    Exit Function

  End If

  getCopyright = VerInfo.LegalCopyright(0) 

End Function







I hope this helps.
--
Dmitry Nikolaev

Did my reply answer your question? Give Kudos or Accept it as a Solution to help others. ⬇️⬇️⬇️
New Here?
Join us and watch the welcome video:
Announcements
Top Kudoed Authors