A wire-cut electric discharge machine having a function of detecting an upper surface of a workpiece, comprising: a mechanism configured to relatively move a wire electrode that is stretched between upper and lower wire guides embedded in upper and lower nozzles with respect to a workpiece that is placed on a workpiece placing table; a contact detection unit (3, 4a, 4b) configured to detect contact between the wire electrode and the workpiece characterised by a movement control unit that relatively moves the wire electrode that is stretched between the upper and lower wire guides with respect to the workpiece after positioning the upper and lower wire guides so that the wire electrode becomes orthogonal to a horizontal surface, then stops the relative movement of the upper and lower wire guides with respect to the workpiece at a first position where contact between the wire electrode and the workpiece is detected, subsequently, relatively moves the upper and lower wire guides with respect to the workpiece, then stops the relative movement of the upper and lower wire guides with respect to the workpiece at a second position that is away from an end surface of the workpiece by a predetermined distance (d 1), subsequently, relatively moves the upper wire guide with respect to the workpiece in a state where the lower wire guide is not relatively moved, and then stops the relative movement of the upper wire guide with respect to the workpiece at a third position where the contact between the wire electrode and the workpiece is detected; a storage unit configured to store positions of the upper and lower wire guides obtained when the relative movement is stopped on the first position, the second position, and the third position; a wire electrode inclination angle calculating unit configured to calculate an inclination angle of the wire electrode lying at the third position from a relative distance (b 1) in a horizontal direction of the upper wire guide obtained when the relative position of the upper wire guide with respect to the workpiece is changed from the second position to the third position and a distance in a vertical direction of the upper and lower wire guides; and a workpiece upper surface position calculating unit configured to calculate a distance (Z 2) from the lower wire guide to the upper surface of the workpiece based on the inclination angle of the wire electrode lying at the third position and a distance (d 1) in a horizontal direction between the lower wire guide and the end surface of the workpiece lying at the third position. a mechanism configured to relatively move a wire electrode that is stretched between upper and lower wire guides embedded in upper and lower nozzles with respect to a workpiece that is placed on a workpiece placing table; a contact detection unit (3, 4a, 4b) configured to detect contact between the wire electrode and the workpiece characterised by a movement control unit that relatively moves the wire electrode that is stretched between the upper and lower wire guides with respect to the workpiece after positioning the upper and lower wire guides so that the wire electrode becomes orthogonal to a horizontal surface, then stops the relative movement of the upper and lower wire guides with respect to the workpiece at a first position where contact between the wire electrode and the workpiece is detected, subsequently, relatively moves the upper and lower wire guides with respect to the workpiece, then stops the relative movement of the upper and lower wire guides with respect to the workpiece at a second position that is away from an end surface of the workpiece by a predetermined distance (d 1), subsequently, relatively moves the upper wire guide with respect to the workpiece in a state where the lower wire guide is not relatively moved, and then stops the relative movement of the upper wire guide with respect to the workpiece at a third position where the contact between the wire electrode and the workpiece is detected; a storage unit configured to store positions of the upper and lower wire guides obtained when the relative movement is stopped on the first position, the second position, and the third position; a wire electrode inclination angle calculating unit configured to calculate an inclination angle of the wire electrode lying at the third position from a relative distance (b 1) in a horizontal direction of the upper wire guide obtained when the relative position of the upper wire guide with respect to the workpiece is changed from the second position to the third position and a distance in a vertical direction of the upper and lower wire guides; and a workpiece upper surface position calculating unit configured to calculate a distance (Z 2) from the lower wire guide to the upper surface of the workpiece based on the inclination angle of the wire electrode lying at the third position and a distance (d 1) in a horizontal direction between the lower wire guide and the end surface of the workpiece lying at the third position.