Both of those sentences are fine in the grammar department.
Long ago there used to be a "rule" (or so some people thought) that one should never put a preposition (like "with") at the end of any sentence. I do not know for sure whether such a rule ever existed, but many people have heard about it.
According to many answers I have read on this site (ell.stackexchange), if such a rule ever existed, it doesn't apply today, and it is now perfectly OK to end a sentence in "with" if you want to. In any case, people fluent in English do it a lot.
In formal highly educated writing, it is common to use the phrase "[preposition] which" to avoid that preposition winding up as the last word in the sentence.
Examples:
1) "Select a directory with which to sync."
&
2) "My uncle wrote the book from which she is going to read."
instead of:
1) "Select a directory to sync with."
&
2) "My uncle wrote the book she is going to read from."
The first pair of sentences are written in a very educated, formal style. Both of them are grammatically correct, but that kind of phrasing is not usually heard in casual conversation. Most native English speakers would choose the second type of sentence structure for speech or informal writing.
But both of the sentences you mention are correct.