Advertisement
pendekar_langit

copy file

Jul 16th, 2015
197
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.18 KB | None | 0 0
  1. #include <iostream>
  2. #include <windows.h>
  3. #include <string>
  4. #include "Shlwapi.h"
  5.  
  6. using namespace std;
  7.  
  8. int main()
  9. {
  10.     string path = "C:\\Users\\devgru\\Desktop\\1";
  11.     CreateDirectory(path.c_str(), NULL);
  12.     if(DirectoryExist(path.c_str()) == true){
  13.         cout << "Create succes !!";
  14.     }
  15.     //CopyFile("C:\\Users\\devgru\\Desktop\\1\\test.txt", "C:\\Users\\devgru\\Desktop\\2\\test.txt", TRUE);
  16.     cout << "Copy succes !!";
  17.     return 0;
  18. }
  19. bool dirExists(const string& dirName_in)
  20. {
  21.   DWORD ftyp = GetFileAttributesA(dirName_in.c_str());
  22.   if (ftyp == INVALID_FILE_ATTRIBUTES)
  23.     return false;  //something is wrong with your path!
  24.  
  25.   if (ftyp & FILE_ATTRIBUTE_DIRECTORY)
  26.     return true;   // this is a directory!
  27.  
  28.   return false;    // this is not a directory!
  29. }
  30. BOOL DirectoryExists(LPCTSTR szPath)
  31. {
  32.   DWORD dwAttrib = GetFileAttributes(szPath);
  33.  
  34.   return (dwAttrib != INVALID_FILE_ATTRIBUTES &&
  35.          (dwAttrib & FILE_ATTRIBUTE_DIRECTORY));
  36. }
  37. BOOL DirectoryExist(const char* dirName) {
  38.   DWORD attribs = ::GetFileAttributesA(dirName);
  39.   if (attribs == INVALID_FILE_ATTRIBUTES) {
  40.     return false;
  41.   }
  42.   return (attribs & FILE_ATTRIBUTE_DIRECTORY);
  43. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement