C#: System.Windows.Forms.FileNameEditor Not Found

This one was a mystery. Since using System.Windows.Forms.Design does not acknowledge that the FileNameEditor class exists, I thought adding a reference to it is the only solution. But which one? There is no System.Windows.Forms.Design DLL. Turned out to be Systems.Design under the .NET tab when you add a reference.

Like what you see? Buy me a cup of coffee. Or subscribe to my feeds.


(No Ratings Yet)
 Loading ...

C#: System.ServiceProcess Not Found

This package does not exist by default when you use the using keyword to import all classes that belong to it. You would have to add a reference to it. On your Visual Studio’s Solution Explorer, right click on References, choose Add and under the .NET tab, look for System.ServiceProcess.

Like what you see? Buy me a cup of coffee. Or subscribe to my feeds.


(No Ratings Yet)
 Loading ...

Java: Sort Files By Date Modified In Descending Order

There came a point that I had to display a list of log files in a certain directory for my boss to view. The important thing with the list display is that the files should be sorted in descending order. From top would be the latest while the oldest would be down at the bottom. Java can do sorting through the Comparator Class. And luckily, I found a post in a forum that saved me the time and trouble to make a custom method for it. The code looks like this.

public static void sortFilesDesc(File[] files) {
  Arrays.sort(files, new Comparator() {
    public int compare(Object o1, Object o2) {
      if ((File)o1).lastModified().compareTo((File)o2).lastModified()) {
        return -1;
      } else if (((File) o1).lastModified() < ((File) o2).lastModified()) {
        return +1;
      } else {
        return 0;
      }
    }
  });
}

Take note that this method includes sorting directories together with the files as one.

Like what you see? Buy me a cup of coffee. Or subscribe to my feeds.


(1 votes, average: 5.00 out of 5)
 Loading ...

MySQL: Show Results Of A Column As 1 Line

Say, your sql result will return multiple rows that may look something like this

id email
1 email1@email.com
1 email2@email.com



There is a pretty useful MySQL function that displays the email addresses found in the 2 rows as one. Using the GROUP_CONCAT(), e.g. GROUP_CONCAT(column_name separator_character) maybe result in something like this

id email
1 email1@email.com email2@email.com



The syntax used was SELECT id, GROUP_CONCAT(email, ‘ ‘)

You can use any other character like comma.

Like what you see? Buy me a cup of coffee. Or subscribe to my feeds.


(No Ratings Yet)
 Loading ...