May 5, 2018 at 7:50pm May 5, 2018 at 7:50pm UTC
Hello,
First post so I apologize if things aren't formatted properly...
Here is the error I am receiving:
Exception thrown at 0x73C0E476 (KernelBase.dll) in updateSchool.exe: 0xC0000005: Access violation writing location
Here is my code:
#include "stdafx.h"
#include <stdio.h>
#include <io.h>
#include <windows.h>
#include <iostream>
int main(void)
{
bool sentinel;
LPCWSTR E = L"E:\\Documents\\1 - School";
//LPCWSTR C = L"C:\\Users\notza\\Documents\\1 - School";
LPWIN32_FIND_DATAW w32fd = 0;
HANDLE hFind;
hFind = FindFirstFile(E, w32fd);
if (hFind != INVALID_HANDLE_VALUE)
{
do
{
DeleteFile(w32fd->cFileName);
} while (FindNextFile(hFind, w32fd));
FindClose(hFind);
}
std::cout << GetLastError() << std::endl;
system("pause");
return 0;
}
As mentioned in the title I would simply like to delete all files within the specified directory.
My ultimate goal is to copy a folder from my C:// drive to an external storage device (E://).
I am using compiler Visual Studio 2017
Any help will be greatly appreciated!
Last edited on May 5, 2018 at 7:51pm May 5, 2018 at 7:51pm UTC
May 5, 2018 at 8:27pm May 5, 2018 at 8:27pm UTC
Last edited on May 5, 2018 at 8:27pm May 5, 2018 at 8:27pm UTC
May 8, 2018 at 11:23am May 8, 2018 at 11:23am UTC
You need append "*.*" to the search passed to FindFirstFile.
You need to pass the address of a WIN32_FIND_DATA instance. You can't pass NULL. How is the function going to return its traversal state if you pass NULL?
May 9, 2018 at 8:31am May 9, 2018 at 8:31am UTC
Was there some problem with simply using the <filesystem>
functions? They exist for a reason.