I am encountering a strange issue when compiling and running a program in Visual Studio Code on Windows. Here’s what happens:
- I wrote a program to add files to a database. Initially, I tested it
with external files, and it worked fine. - After integrating the file manipulation code into my source code, I
encountered some errors. I fixed those and tried to run the program. - Upon running the .exe file, it disappeared from the directory
without any error messages.
I suspected Windows Defender might be causing this, as I found a 13-year-old article suggesting it could delete files it deems unsafe.
I added exclusions in Windows Defender for both the .exe file and the project folder. However, the issue persists.
I tested the setup by compiling a simple “Hello, World” program, and it worked fine. This issue only occurs with the program involving file operations.
What I’ve Tried:
Running Visual Studio Code as an administrator.
Adding exclusions in Windows Defender for the .exe file and the entire project folder.
What might be causing it:
case 5:
std::cout << "Enter the file path to upload: ";
std::getline(std::cin >> std::ws, filePath);
// Insert the file into the database and display its content.
if (insertFileIntoDatabase(db, filePath)) {
printDatabaseContent(db);
}
std::cout << "uploading file(s)..." << std::endl;
break;
case 9:
std::cout << "Exiting the program...n";
return;
default:
std::cerr << "Invalid choice. Please try again.n";
}
}
I suspect that this is the problem, however I just don’t understand why, and I can’t find a way to fix my problem.
This is the code where the user inputs a file path, and the program attempts to insert the file into the database. Could this operation be causing Windows Defender to flag and remove the .exe file?
1