Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C / C++ / MFC
  4. deleting a empty folder from a specified path

deleting a empty folder from a specified path

Scheduled Pinned Locked Moved C / C++ / MFC
tutorial
2 Posts 2 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • N Offline
    N Offline
    neha agarwal27
    wrote on last edited by
    #1

    I want to delete a empty folder present at a specified path. I am using this code for doing this:- <pre> CString fol_Path = _T("C:\\Program Files\\New Folder"); if(_taccess(fol_Path, 0) != -1) { Attributes = GetFileAttributes(fol_Path); if(Attributes != 0xFFFFFFFF) { SetFileAttributes(fol_Path,FILE_ATTRIBUTE_NORMAL); _wunlink(fol_Path); } } </pre> but my _wunlink function is returning -1 value..... i am using unicode..... can anbody tel me how to do this..... thanks in advance

    M 1 Reply Last reply
    0
    • N neha agarwal27

      I want to delete a empty folder present at a specified path. I am using this code for doing this:- <pre> CString fol_Path = _T("C:\\Program Files\\New Folder"); if(_taccess(fol_Path, 0) != -1) { Attributes = GetFileAttributes(fol_Path); if(Attributes != 0xFFFFFFFF) { SetFileAttributes(fol_Path,FILE_ATTRIBUTE_NORMAL); _wunlink(fol_Path); } } </pre> but my _wunlink function is returning -1 value..... i am using unicode..... can anbody tel me how to do this..... thanks in advance

      M Offline
      M Offline
      Michael Schubert
      wrote on last edited by
      #2

      You're using a rather bizarre mixture of Win32, tchar and _UNICODE functions. I assume you have checked elsewhere that the folder you want to delete is empty, right? Also, you don't have to use GetFileAttributes() since you want to delete the folder anyway. Most importantly, check the return code from SetFileAttributes() with GetLastError(). If that is successful, use RemoveDirectory() and again check the return value with GetLastError().

      1 Reply Last reply
      0
      Reply
      • Reply as topic
      Log in to reply
      • Oldest to Newest
      • Newest to Oldest
      • Most Votes


      • Login

      • Don't have an account? Register

      • Login or register to search.
      • First post
        Last post
      0
      • Categories
      • Recent
      • Tags
      • Popular
      • World
      • Users
      • Groups