C + + CopyFile ()

Source: Internet
Author: User
Tags windows 7 x64

For CopyFile function, refer to: https://msdn.microsoft.com/en-us/library/windows/desktop/aa363851 (v=vs.85). aspx

Ide:code::blocks 16.01

Operating system: Windows 7 x64

1#include <windows.h>2#include <stdio.h>3 4 intMain ()5 {6 DWORD dwerror;7 8     if(CopyFile ("H:\\c++\\newdirectory\\file.txt","H:\\c++\\newdirectory\\del.bat", FALSE)) {9printf"Copy file succeeds. \ n");Ten     } One     Else { ADwerror =GetLastError (); -         Switch(dwerror) { -          CaseError_file_not_found: theprintf"The source file does not exist. \ n"); -printf"Error:%ld \ n", dwerror); -              Break; -         default: +printf"The new file already exists. \ n"); -printf"Error:%ld \ n", dwerror); +              Break; A         } at     } -  -     return 0; -}

Ide:microsoft Visual Studio Community 2017 15.5.2

Operating system: Windows 7 x64

1#include"stdafx.h"    /*created by the IDE itself*/2 3#include <windows.h>4 5 intMainintargcChar**argv)6 {7 DWORD dwerror;8 9     if(CopyFile (L"H:\\c++\\newdirectory\\file.txt", L"H:\\c++\\newdirectory\\del.bat", FALSE)) {Tenprintf"Copy file succeeds. \ n"); One     } A     Else { -Dwerror =GetLastError (); -         Switch(dwerror) { the          CaseError_file_not_found: -printf"The source file does not exist. \ n"); -printf"Error:%ld \ n", dwerror); -              Break; +         default: -printf"The new file already exists. \ n"); +printf"Error:%ld \ n", dwerror); A              Break; at         } -     } -  - GetChar (); -  -     return 0; in}

C + + CopyFile ()

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.