Mr. Lapes, 49, has been willing to weather the blistering response because of how lucrative these shelters have become. Mr. Lapes, who has a home in Upper Saddle River, N.J., that was valued in 2005 at $3.3 million, did not return numerous messages left at his home, office and homeless shelters seeking comment.

The fact that these modest living spaces have such high rents opens a window on a peculiarity of the city’s overall homeless policy. That policy, which was put in place in response to court settlements in 1979 and 2008, requires the city, under threat of sizable fines, to find a roof immediately for every homeless person. It has given landlords willing to house the homeless leverage to dictate rental prices and other terms.

Although the 95th Street shelter where Mr. Machan lives has been opened under “emergency” rules, the contract is for five years at $122 daily per room and will cost the city a total of $47 million. “We’ve tried hard to make sure we’re getting the best deal for the city,” Seth Diamond, the commissioner of homeless services, said at the meeting in response to the criticism.

With the number of homeless people rising to 30-year record levels — over 47,216 people as of early this month, 20,000 of them children — the city has struggled to find landlords willing to accommodate a population that includes people with mental health and substance abuse problems. So the city has resorted to housing adults in single-room-occupancy buildings originally designed for long-term residents who pay stabilized rents. The city also often relies on sites with troubled histories, like a long vacant 10-condominium building at 165 West Ninth Street in Carroll Gardens, Brooklyn, owned by Mr. Lapes, where it wants to house 170 homeless men.

“How many landlords are out there who, if you said I need 200 rooms by the end of the month, would have these properties ready to go?” said Muzzy Rosenblatt, the chief executive of the Bowery Residents Committee, a nonprofit organization that operates six well-regarded shelters. “There are not a lot of landlords banging down the door.”

At several of Mr. Lapes’s shelters, tenants — both homeless and longer-term residents — say the buildings are often characterized by violence, drug-use, mice, broken elevators, periods without heat and hot water, and violations of fire safety laws. At 237 West 107th Street, a six-story women’s shelter formerly known as the West Side Inn, many of the 200 tenants said they often waited for an hour or more to take a shower at one of the shared bathrooms on each floor.

Joyce Colon, a resident there who entered the homeless system in December, said she was shocked by the violence and prostitution in the building.