Another thread that devolves into a random list of various stations' affiliations histories...but let's try a little deeper here and limit ourselves just to stations that have been affiliated with (but not owned by) their networks since at least the 1940s.
Detroit's WWJ-TV/WDIV 4 has to be at or near the top of that list; it signed on in early 1947 and has been with NBC from the beginning. KSD-TV/KSDK in St. Louis was also an early 1947 sign-on and has stayed with NBC from day one. WTMJ-TV in Milwaukee came on later in 1947 and is also an NBC lifer. In addition to KPRC, other early NBC affiliates that have stayed with the network all along include KOB Albuquerque (1948), WBAP-TV/KXAS Fort Worth (1948, but eventually an O&O), WLWT Cincinnati (1948), WAVE Louisville (1948), WDSU New Orleans (1948), WJAR Providence (1949), WCMH Columbus (1949), WICU Erie (1949), WGAL Lancaster (1949), WJAC Johnstown (1949), WKTV Utica (1949), WOAI-TV/KMOL/WOAI-TV San Antonio (1949) and WLAV-TV/WOOD-TV Grand Rapids (1949).
On the CBS side, WBEN-TV/WIVB Buffalo signed on in 1948 and has been primary CBS since at least early 1949. WTVR Richmond was also a 1948 debut, but didn't become primary CBS until 1955. KPIX-TV San Francisco signed on in 1948 and has always been CBS, but eventually as an O&O. That, I think, makes WHEN-TV/WTVH in Syracuse the longest-running primary CBS station that's not an O&O, since it signed on in December 1948 with CBS primary. WOIC/WTOP/WDVM/WUSA-TV in Washington can also claim CBS as far back as early 1949. WHIO-TV in Dayton (1949), KFMB-TV San Diego (1949), WNBF-TV/WBNG Binghamton (1949), WBNS-TV Columbus (1949), WCCO-TV Minneapolis (1949, later an O&O) and WBTV Charlotte (1949) round out the pre-1950 CBS lineup that's stayed with the network all these years.
In Philadelphia, WFIL-TV 6 was with ABC from its start in 1947, long before it became WPVI and eventually ended up as an ABC O&O. If you rule WPVI out on those grounds, the next stop would be WTVW/WMAL-TV/WJLA in Washington, which was primary CBS when it signed on in 1947 but was primary ABC by 1948 when DC became a four-station market. Past there and WTVN-TV/WSYX Columbus (1949 as secondary ABC, but primary DuMont until 1955), you're into the 1950s before you find the next stations that have maintained continuous primary ABC affiliation.