ignorance of the law is no excuse
The statement "ignorance of the law is no excuse" is an ancient legal doctrine: Ignorance of the law excuses no man; not that all men know the law; but because 'tis an excuse every man will plead, and no man can tell how to confute him. John Selden (1584-1654), posthumously published in Table Talk, 1689.
If a defendant were allowed to escape legal responsibility for his acts, merely by saying "I didn't know it was wrong/illegal", the system of using law to regulate human conduct would collapse. So the doctrine is a practical necessity.
This doctrine still has vitality and validity today. See, for example, Ratzlaf v. U.S., 510 U.S. 135, 149 (1994); U.S. v. Freed, 401 U.S. 601, 612 (1971) (Brennan, J., concurring); Minnesota v. King, 257 N.W.2d 693, 697 (1977).
However, the law in the USA has swelled to a size that is unknowable even by experts. In Oct 1998, the annotated edition of the U.S. Code (i.e., federal statutes) occupied 32 feet of library shelf space. In Oct 1998, the annotated edition of the New York state statutes occupied 22 feet of library shelf space. Who can know all that is within these pages? A criminal law class in law school contains only about 40 hours of lectures, mostly about homicides, with a little about larceny and rape. The only solution seems to be a detailed search of statutes and cases in a database on a computer (e.g., WESTLAW), plus the avoidance of any behavior that harms people, either through physical, financial, or emotional injury, or by deceit.
A related concept in law is "wilful blindness": the criminal defendant who should have known, and could have asked, but deliberately chose not to ask. The law regards "willful blindness" as equivalent to knowledge. U.S. v. Jewell, 532 F.2d 697, 700-701 (9th Cir. 1976), cert. denied, 426 U.S. 951 (1976). Cited with approval in U.S. v. Lara-Velasquez, 919 F.2d. 946, 950-951 (5th Cir. 1990).