They are pretty similar, but で usually indicates that an action took place at that location. So you use に when you're talking about being inside or next to something, etc. and で when you talk about doing something inside or next to something.
Edited to add: 部屋の中で泣いている is correct, because the room is the location of an action (crying).