There is a very small difference in meaning between the two forms. The -ing form emphasises the action or experience. The to-infinitive gives more emphasis to the results of the action or event. We often use the -ing form to suggest enjoyment (or lack of it), and the to-infinitive form to express habits or preferences. Cambridge Dictionary
I couldn't understand what they mean by "emphasises the action" and "emphasis to the results". as example, which of the following sentence is correct?
I don't like surprises. I like knowing things in advance.
I don't like surprises. I like to know things in advance.