Electron transport in thin metallic wires and films is strongly influenced by the quality of their surface. Weak localization and magnetoconductivity are also sensitive to the electron scattering at the edges of the sample. We study weak localization effects in a two-dimensional electron gas patterned in the form of a narrow quasi-one-dimensional channel in transverse magnetic field. The most general boundary conditions interpolating between the limits of mirror and diffuse edge scattering are assumed. We calculate magnetoconductivity for an arbitrary width of the sample including the cases of diffusive and ballistic lateral transport as well as the crossover between them. We find that in a broad range of parameters, the electron mobility is limited by the boundary roughness, while the magnetotransport is only weakly influenced by the quality of the edges. In addition, we calculate magnetoconductivity for a metallic cylinder in the transverse field and a quasi-two-dimensional metallic film in the parallel field.