The 1851 Census (Queensbury, York Co NB, p10)shows William with his parents, Henry, age 56, & Phebe [Adams] Niles, age 54.
Unsourced public trees give Henry's parents as: James (b c1760 NY; d 1820) and Rebecca Johnson (1763-1835). James is indicated as immigrating from NY in 1783, age 23.
While James may have immigrated from NY I doubt he was born there. Instead he may be (no proof) the son of Samuel and Elizabeth (Reynolds) Niles of Middleborough Mass who served several years on the American side of the Rev War and then joined the British cause at Peekskill NY on 5 Jan 1780, age 20[Mass Soldiers & Sailors]. At the war's end in 1783 the Brits gave Loyalists safe passage to Nova Scotia and other parts of Canada.Two of James children are named Samuel and Elizabeth (a coincidence, perhaps). I've not found records in Mass naming Samuel and Elizabeth's after their marriage in 1755.
A search of York County, NB, land, court, and probate records might prove James the father of Henry.