I'm just trying to write a simple program that clears out my "Path" folder exept for 2 .exe files preselected. The problem is that I only succeed in deleting the first one (file1.exe). What am I doing wrong? Forgive me if I'm using the logical operators but in this moment is like my head is about to explode...
string[] filePaths = Directory.GetFiles(Path); foreach (string filePath in filePaths) { var name = new FileInfo(filePath).Name; name = name.ToLower(); if (name != "file1.exe" || name != "file2.exe") { File.Delete(filePath); } }