Thermal vapor condensation of melamine at various temperatures was used to fabricate thin graphitic carbon nitride (g-C3N4) films on fluorine-doped tin oxide (FTO) coated glass substrates. Photoanodic (n-type) and photocathodic (p-type) responses were observed simultaneously in the g-C3N4 films. The g-C3N4 film formed at 520 °C with the longest average lifetime of the photo-excited electrons shows the best cathodic photocurrent performance, which was then chosen for electrochemical and photoelectrochemical reduction of CO2. When the basic electrolyte (CO2-saturated 0.5 M KHCO3, pH = 7.6) was adopted, CO2 was electrochemically converted into formaldehyde ((54.6 μM/h)) in the liquid product. When the acidic electrolyte (CO2-saturated 0.5 M KCl, pH = 4.1) was adopted, formaldehyde (39.5 μM/h) and ethanol (15.7 μM/h) were generated through photoelectrochemical reduction, stimulated by the presence of sufficient protons from the electrolyte in the reduction process. Therefore, the pure g-C3N4 film has a great potential for CO2 reduction to value-added liquid hydrocarbons products via electrochemical or photoelectrochemical ways.