In some cases, e.g Nazi Germany or wartime Britain, 'enemy' investors were paid off in compensation and forced to withdraw. Communist regimes (e.g. Soviet Russia) nationalised industry without compensation. But there have been cases in history where a state has continued to allow the 'enemy' to invest in its industry, e.g. in the US Civil War and in World War 1 arms companies sold to both sides, and during the Falklands War, Argentine/British investments were left alone. So it's all down to whoever controls the national political economy and what their policies are.