This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
foreach (var s in DriveInfo.GetDrives()) | |
{ | |
if (s.IsReady) | |
{ | |
Console.WriteLine(s.Name); | |
Console.WriteLine(s.TotalSize); | |
Console.WriteLine(s.AvailableFreeSpace); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Program | |
{ | |
static int threadID=0; | |
[System.Runtime.InteropServices.DllImport("kernel32.dll")] | |
static extern IntPtr OpenThread(uint dwDesiredAccess, bool bInheritHandle, uint dwThreadId); | |
[System.Runtime.InteropServices.DllImport("kernel32.dll")] | |
static extern bool TerminateThread(IntPtr hThread, uint dwExitCode); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class MyClass | |
{ | |
public MyClass() | |
{ | |
Console.WriteLine("MyClass is created!"); | |
} | |
} | |
public class Program |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class Program | |
{ | |
public static int StaticInt = 0; | |
static Func<string> delegate1 = new Func<string>(StaticInt.ToString); | |
static Func<string> delegate2 = new Func<string>(() => StaticInt.ToString()); | |
static void Main(string[] args) | |
{ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class NoDerive { | |
NoDerive(){}; | |
public: | |
static NoDerive GetNoDerive(){ return NoDerive();}; | |
~NoDerive(){}; | |
}; | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <iostream> | |
#include <assert.h> | |
using namespace std; | |
class B; | |
class A | |
{ | |
public: | |
A(); | |
~A(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public static bool IsFatal(this Exception exception) | |
{ | |
while (exception != null) | |
{ | |
if (exception as OutOfMemoryException != null && exception as InsufficientMemoryException == null || exception as ThreadAbortException != null || | |
exception as AccessViolationException != null || exception as SEHException != null || exception as StackOverflowException != null) | |
{ | |
return true; | |
} | |
else |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
static class ProcessDetector | |
{ | |
public static bool IsWin64(Process process) | |
{ | |
if (Environment.Is64BitOperatingSystem) | |
{ | |
IntPtr processHandle; | |
bool retVal; | |
try |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
ObjectToSerialize objectToSerialize = new ObjectToSerialize(); | |
StringBuilder sb = new StringBuilder(); | |
XmlSerializerNamespaces ns = new XmlSerializerNamespaces(); | |
ns.Add("", ""); | |
XmlWriterSettings settings = new XmlWriterSettings(); | |
settings.OmitXmlDeclaration = true; | |
XmlWriter xmlWriter = XmlWriter.Create(new StringWriter(sb), settings); | |
xmlSerializer.Serialize(xmlWriter, objectToSerialize, ns); | |
Console.WriteLine(sb.ToString()); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//Now Create all of the directories | |
foreach (string dirPath in Directory.GetDirectories(SourcePath, "*", | |
SearchOption.AllDirectories)) | |
Directory.CreateDirectory(dirPath.Replace(SourcePath, DestinationPath)); | |
//Copy all the files | |
foreach (string newPath in Directory.GetFiles(SourcePath, "*.*", | |
SearchOption.AllDirectories)) | |
File.Copy(newPath, newPath.Replace(SourcePath, DestinationPath)); |