Skip to content

Instantly share code, notes, and snippets.

View kyrathasoft's full-sized avatar

William.Miller kyrathasoft

View GitHub Profile
@kyrathasoft
kyrathasoft / capName.cs
Created October 3, 2019 19:15
shows use of method ProperlyCapitalizeName
using System;
using System.Text;
namespace Example {
class Program {
static void Main(string[] args){
string[] words = {"mr.", "bryan", "miller"};
for(int i=0; i < words.Length; i++){
@kyrathasoft
kyrathasoft / CopyDirToDir.cs
Created October 2, 2019 23:20
demonstrates method CopyTo
/* shows how to count the number of top-level
subdirectories within a given directory
online at:
https://gist.github.com/kyrathasoft/d130f93dce7fb45341d18e6872b192cd
To compile, use build.bat. Or, at the command line:
csc /out:copydir.exe *.cs
Here is the structure of this example program
@kyrathasoft
kyrathasoft / CopyTo.cs
Created October 2, 2019 23:16
A method that faithfully copies an entire directory structure to another directory
public static bool CopyTo(string targetDirectory, string destinationDirectory)
{
bool blnSuccess = false;
try{
if(Directory.Exists(targetDirectory)){
foreach (string dirPath in Directory.GetDirectories(targetDirectory, "*",
SearchOption.AllDirectories)){
Directory.CreateDirectory(dirPath.Replace(targetDirectory, destinationDirectory));
}
@kyrathasoft
kyrathasoft / countTopDirs
Created October 2, 2019 00:45
example of how to count the number of top-level subdirectories contained in a given directory
/* shows how to count the number of top-level
subdirectories within a given directory
To compile: csc /out:count.exe *.cs
Here is the structure of this example program
and associated directories, on disk:
examples/CountTopLevelDirectories
- countTopDirs.cs (file)
@kyrathasoft
kyrathasoft / sorting.cs
Created June 14, 2019 22:03
Demo sorting List<DateTime> ascending and descending
using System;
using System.Collections.Generic;
namespace ExampleOfOrderingByDate {
class OrderingByDate{
public static List<DateTime> myList;
public static void Main(string[] args){
@kyrathasoft
kyrathasoft / cull.cs
Created June 9, 2019 23:15
cull non essential files from /examples prior to archiving
using System;
using System.IO;
using System.Collections.Generic;
using com.wms.dirs;
using com.wms.files;
/*
You'll first need to compile dirs.dll from com_wms_dirs.cs. That source code is found
in c:\csdev\library\dirs_dll\, or at these URLs:
+ https://gist.github.com/kyrathasoft/aca4a458ce58edb05f4476a8186cae33
@kyrathasoft
kyrathasoft / com_wms_dirs.cs
Created June 9, 2019 13:24
source code for compiling dirs.dll library
using System;
using System.IO;
using System.Collections.Generic;
namespace com.wms.dirs{
public class ClassDirs{
public static int CountDirectoriesRecursively(string targetDirectory)
{
@kyrathasoft
kyrathasoft / com_wms_zip.cs
Created June 9, 2019 12:47
methods support zip archive creation, extraction, and manipulation of ZipEntries
using System;
using System.IO;
using System.IO.Compression;
using System.Collections.Generic;
using System.Text;
namespace com.wms.zip{
public class ClassZip{
@kyrathasoft
kyrathasoft / ImgBase64.cs
Last active June 7, 2019 16:33
demonstrates use of two methods in crypt.dll to convert between images and their Base64-encoded strring representations
using System;
using System.IO;
using com.wms.crypt;
namespace ConsoleApplication {
//uses crypt.dll produced from this src code: https://gist.github.com/kyrathasoft/f436e4bfaed8bf2f43f7d72916a4e670
class Program{
static void Main(string[] args){
@kyrathasoft
kyrathasoft / com_wms_crypt.cs
Last active June 7, 2019 16:27
Source code from which I build crypt.dll
using System;
using System.IO;
using System.Security.Cryptography;
using System.Drawing;
namespace com.wms.crypt{
/*
+ https://gist.github.com/kyrathasoft/f436e4bfaed8bf2f43f7d72916a4e670
+ https://pastebin.com/RNinZTiz