The Problem:
I have two polygons feature classes, let's call them "SourceAreas" and "DangerAreas". For each SourceArea, I need to know if water could flow to any DangerArea and if so, what is the minimum distance that the water would flow before it reaches any DangerArea.
Using ArcGIS Desktop 10.5.1.
What I Have Tried:
I have used a DEM to create a flow direction raster and then a flow accumulation raster with weights based on my SourceAreas (all other cells with a zero weight), and then a "Streams" feature class using the 'Stream to Feature' tool (Spatial Analyst -> Hydrology).
So now I can clearly see all possible water flows from all of my SourceAreas on the map, and visually I can see if they intersect any of my DangerAreas downstream.
However, there are a LOT of these and I need to automate the process, and to measure flow distances. The attached screenshot illustrates a small sample of my overall area of interest. The red areas are the SourceAreas, the yellow is the DangerAreas and the blue lines are the streams.
I have tried creating a geometric network from the streams feature class and was going to try to do a trace downstream from all the points where the streams intersect my SourceAreas. But this has not proved useful for this purpose (at least not without a lot of additional processing).
I then moved on to Linnear Referencing. Created routes from the stream feature class, and tried to Locate Features Along Routes. But after leaving it running for hours, I gave up. Again, even if it worked, I'm not sure I could use the results to achieve what I want.
So my third attempt was to create a Python script which finds all starting nodes of the stream network, then using cursors, traces each route to its terminus by connecting the 'to_node' of one feature to the 'from_node' of the next and builds a single simple line along the way by unioning the geometries of all the connecting line features. The resulting long line is then inserted (again using cursors) into a 'Routes' feature class. The idea being that every possible route that water could take is now represented by a single part line feature with no branches. I'm confident that this could be used to get the results I need - if it ever finished running. Edit: This took about 6 days to run, and by then I'd solved it using something similar to the answer provided below.
What is the best way to determine, for each SourceArea, what is the minimum distance to any downstream DangerArea?
Update - new 'Flow Distance' tool: I've just discovered that there is a new ArcGIS Tool called 'Flow Distance' that looks like it should do exactly what I want. Unfortunately, it is only available in ArcGIS 10.6 and up, and we are on 10.5.1 - just one version shy of having this tool.