Category Archives: Utility

Quick trick : Copy file path

Are you in a command line prompt and you need the full path of the file as an argument? You don’t need to type all of the path manually, not even pre-complete it using TABs. Just navigate to the file.
Here comes the trick part : hold SHIFT while right-clicking it. The context menu will look like so :

SHIFT-right-click-copy-as-path-contextual-menu-command

I wrote before about the SHIFT-right click so this is somehow connected.

You will then have the full path of the file in the clipboard ready to be pasted wherever you need.

Hope this helps someone! 🙂

Character test utility

Every now and then I have to decide if a character satisfies a predicate (char.IsPunctuation, char.IsSymbol and so on) found on the System.Char class. The MSDN pages are of limited help plus I need to browse each predicate. Therefore I wrote a small piece of code that, aside from the fact that it’s quite simple and has nothing spectacular, tests a set of characters through all these predicates.

Basically this is a reference for me, in order to avoid rewriting this over and over again, but since it could be helpful to others too I decided to publish it here.


using System;
using System.Linq;

namespace CharTest
{
    internal class Program
    {
        static void Main()
        {
            var charPredicates = new Predicate<char>[]
            {
                char.IsControl, 
                char.IsDigit, 
                char.IsHighSurrogate, 
                char.IsLetter,
                char.IsLetterOrDigit,
                char.IsLowSurrogate, 
                char.IsLower, 
                char.IsNumber, 
                char.IsPunctuation, 
                char.IsSeparator, 
                char.IsSurrogate, 
                char.IsSymbol, 
                char.IsUpper, 
                char.IsWhiteSpace
            };

            Console.WriteLine("Enter an empty line to exit");
            Console.WriteLine();
            Console.WriteLine();

            string line;
            do
            {
                line = Console.ReadLine();
                var chars = line.Distinct().ToArray();
                for (var i = 0; i < chars.Count(); i++)
                {
                    var ch = chars[i];
                    Console.WriteLine();
                    Console.WriteLine("Distinct character " + (i + 1) + " : '" + ch + "'");
                    Console.WriteLine("-----------------------------------------");
                    foreach (var predicate in charPredicates)
                    {

                        Console.Write(predicate.Method.Name);
                        Console.SetCursorPosition(20, Console.CursorTop);
                        Console.WriteLine(predicate(ch));
                    }
                }
            }
            while (line != "");
        }
    }
}