title: listFiles() returns null when it shouldn't. It used to work properly until recently and hasn't been modified
body: <pre><code>public static void main(String[] args) throws InterruptedException {
      // TODO Auto-generated method stub
      while(true)
      {
          ArrayList&lt;File&gt; wallpapers = new ArrayList&lt;File&gt;();
          File dir = new File("C:/Windows/System32/oobe/info/backgrounds/");
          if(dir.listFiles() == null)
              System.out.println("Empty");
          for(File img : dir.listFiles())
          {
              if(img.getName().endsWith(".jpg") &amp;&amp; img.getName() != "backgroundDefault.jpg")
                  wallpapers.add(img);
          }
          File current = new File("C:/Windows/System32/oobe/info/backgrounds/backgroundDefault.jpg");
          int i = 1;
          for(File img : wallpapers)
          {
              File f = new File("C:/Windows/System32/oobe/info/backgrounds/"+ i++ +".jpg");
              current.renameTo(f);
              File file = new File("C:/Windows/System32/oobe/info/backgrounds/backgroundDefault.jpg");
              img.renameTo(file);
              Thread.sleep(60000);
          }
  
      }
  }   }
  }
  </code></pre>
  
  <p>This code changes the background image of the Windows Log In screen every minute.
  listFiles() returns null for dir and I get a NullPointerException on for(File img : dir.listFiles()). I thought there may be a problem with file rights so I tried to change the file path to a directory I have on my Desktop and it works fine. So I'm assuming I can't access system files because my program doesn't have enough rights. Let me also precise that this code used to work fine until recently. It hasn't been modified. I just found out that my Log In Wallpaper doesn't change anymore.
  Even when the program did work I couldn't modify the file name when I launched the program through Eclipse but I would export it as .jar and schedule it with Task Scheduler with highest privileges to give it admin rights and it worked without any problems until recently. I also tried ignoring the errors thinking they were related to access rights and tried to launch my executable jar with highest privileges through Task Scheduler and also using a batch file. I even tried launching the jar through a cmd I opened with Administrator Rights to no avail it still says NullPointerException in the cmd. I'm kind of lost and would appreciate any help.</p>