title: Delete file older than 30 days
body: <p>I have been trying to Delete file in a Folder which is Older than 30 days,
  below is the code, in which I am trying to get the File save date, but its not returning clearly.</p>
  
  <p><a href="https://i.stack.imgur.com/weQNy.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/weQNy.png" alt="I have attached the image "></a></p>
  
  <pre><code>char c_szText[_MAX_PATH];
  wcstombs(c_szText, username, wcslen(username) + 1);
  
  std::string Fstr("c:\\Users\\username\\AppData\\Test\\*");
  Fstr.replace(9, 8, c_szText);
  
  const time_t t = time(NULL);
  struct tm* tl = localtime(&amp;t);
  
  WIN32_FIND_DATA info;
  HANDLE hp;
  hp = FindFirstFile(str2.c_str(), &amp;info);
  do
  {
      FILETIME ftCreate, ftAccess, ftWrite;
      SYSTEMTIME stUTC, stLocal;
      DWORD dwRet;
  
      LPTSTR lpszString;
      GetFileTime(hp, &amp;ftCreate, &amp;ftAccess, &amp;ftWrite);
      // Convert the last-write time to local time.
      FileTimeToSystemTime(&amp;ftWrite, &amp;stUTC);
      SystemTimeToTzSpecificLocalTime(NULL, &amp;stUTC, &amp;stLocal);
      if (tl-&gt;tm_year + 1900 &gt; stLocal.wYear)
      { 
          DeleteFile(info.cFileName);
      }
      else if ((tl-&gt;tm_mon - ((stLocal.wMonth) - 1)) &gt; 1)
      {
          DeleteFile(info.cFileName);
      }
      else if(tl-&gt;tm_mon &gt; ((stLocal.wMonth)-1))
      {
          if(tl-&gt;tm_mday &lt;= stLocal.wDay)
          { 
              DeleteFile(info.cFileName);
          }
      }
  } while (FindNextFile(hp, &amp;info));
  FindClose(hp);
  </code></pre>
  
  <p>Can anyone guide me how to achieve this?</p>