on the way; in the middle of~
途中で indicates that something happens in the middle of a journey or an ongoing action.
途中で literally means 'on the way' or 'in the middle of'. When used with a destination, it means that something occurs before reaching that destination. For example, if you are going to work and you stop at a convenience store, you can say 仕事に行く途中でコンビニに寄った. It can also be used with an action to mean 'in the middle of doing' that action, like 昼ご飯を食べている途中で電話が来た. In this case, it is similar to 最中に, but 途中で is more general and can also refer to a part of a process, not just a specific moment. It is a common expression in both spoken and written Japanese, and it is not particularly formal or informal.