On July 13, 1863, Flanders was made the Captain of Company C, 5th Regiment Louisiana Volunteers, a Union Army unit. He was honorably discharged in August 1863, when he was appointed a Special Agent of the United States Treasury Department of the Southern Region by Secretary of the Treasury Salmon P. Chase. He held this position until 1866. While in office, he generated commissions for the government by selling confiscated cotton from Confederate plantations. The Department of Treasury controlled licensing of cotton brokers, trying to regulate the market, but a black market flourished for the lucrative sale of cotton.