A method of calculating the longitudinal magnetoresistance of ultrathin films or inversion layers in MOS structures with sufficient size quantisation of transverse electron motion is proposed within the framework of the theory of weak localisation. The cases when a single subband and several subbands of size quantisation are filled are discussed. It is shown that in all studied cases the magnetoresistance is negative and depends on the ratio H2/T, so that it can be distinguished experimentally from the H/T-dependences of electron-electron interaction corrections to conductivity. Extension of the obtained results to the magnetoresistance calculation of quasi-1D channel is also discussed.