A Pennsylvania railroad man, McIlvaine joined Company H of the 97th Regiment Pennsylvania Volunteers on October 17, 1861, and rose to the rank of Captain before his resignation and retirement from military service on June 10, 1863.
In 1880, he moved to West Virginia and began his post-military career as a minor author and amateur mycologist. Century Magazine, Harper's Magazine, and similar periodicals, as well as by the Detroit Free Press published a mix of sketches, poems and short stories, often written in an approximation of the rural West Virginia dialect. He also wrote at least two book-length works. He used the pseudonym Tobe Hodge for much of his writing.
He is better known, however, for his study of mushrooms. McIlvaine compiled his notes into the book One Thousand American Fungi, still named as a "classic" work of American mycology. In his writings, he was a constant proponent of the dietary value of mushrooms, and it is for this interest in the edibility of fungi that he is most remembered. He consumed hundreds of species, including some (such as the acrid Russula emetica and bitter Hypholoma fasciculare) that are generally considered poisonous, earning him the nickname 'Ole Ironguts'. His experimentation was not without caution, however, and he did not die of mushroom poisoning, instead passing away of natural causes.
The journal of amateur mushrooming, McIvainea, Published by the North American Mycologic Association, is named in his honor.