Quickly Find Day of the Week – C#

Hi all! This is just a random post to show off something new I found. I don’t claim credit for this algorithm and if you’re curious as to how it works then this Wikipedia article may be of interest to you. This post has a good explanation of why the algorithm works in the first …

File Shredder Code Sample (C# 4.0)

It has been a while since I last posted a code sample. So here is one for you guys to take a look at. Below is the file/directory shredder class. class FileUtilities { private static Random Randomizer = new Random(); public static bool Shred(string directoryPath, bool shouldDelete = true) { bool success = true; try …

CSIT and Network Information

Hi guys! Network information is a complex subject at the best of times and simplifying it for the average user is no simple feat. Even harder it seems is actually writing code to get this information programatically! I was quite disappointed to find that there was no simple way to get an IP address via …

Calling the __cpuid MSVC function via C# a DLL Pinvoke (C++, C#)

Here is the latest piece of code I wish to share with everyone since I run into this myself, I am sure others will be interested also. The C++ Part Firstly you will need to create a new DLL project in Visual Studio. You will also need to add this line into the cpp file …

First Code Snippet – Simple Hertz and Bytes Converters (C#)

Hi everyone! These are my first code snippets. These were written as part of my CSIT project and are used to convert sizes and frequencies easily from one type to another. First lets look at the byte conversion function. [cc lang=”c#”] public enum ByteUnits : int { B, kB, MB, GB, TB, PB } public …