Coding

All things computer programming related...

Capture console output in C#

- Posted in Coding by

The following C# source code demonstrates how to capture the output of a console program:

Unresolved assembly reference

- Posted in Coding by

Sometimes you'll get “Unresolved assembly reference not allowed” when attempting to use ILMerge. To avoid this, specify the full path to the framework you're targeting, like this:

ilmerge /targetplatform:v4,"C:WindowsMicrosoft.NETFramework64v4.0.30319" /out:merged.exe myprogram.exe mylib1.dll mylib2.dll

ZipFolder

- Posted in Coding by

using ZipFolder from the Windows command-line

ZipFolder is a nifty little Windows command-line utility that is passed two arguments: (1) the folder that is to be compressed into a .zip archive, and (2) the name of the resulting archive (with .zip extension)

Note: this utility requires that you have installed the .NET Framework 3.5 but Windows should prompt you to install it, if it is missing.

The usefulness of this CLI utility lies in the fact that we can leverage it from programming code. Aside from that scenario, most Windows users won't find much reason to use it.

↓ZipFolder

Code Obfuscators

- Posted in Coding by

Although it's probably the case that the hobbyist developer needn't worry too much about his .NET CIL code being decompiled, there are some free assembly obfuscators that seem to work: OrangeHeap (~ 1.35 Mb download) and Confuser (~2.2 Mb download; available here). I prefer the latter.

Tools like these have a way of becoming vaporware. Nevertheless, at the time I write this, you can find OrangeHeap here on the internet, and Confuser here.

Roll dice

- Posted in Coding by

Sometimes you just want to use a simple online dice roller; at other times, you want to roll one yourself using your favorite programming language.

It can be useful to generate random numbers using C#. Here is a zipped Visual Studio Community 2022 project demonstrating rolling d6 dice. And below, I've inlined the Github gist of the class I'm using.

Website encapsulation into an executable

- Posted in Coding by

There are a couple of different ways (that I know about) to encapsulate a website (or just a subdirectory?) into an executable. There is Web2Executable and Nativefier via nodejs.

I'm basically only noting these here on the chance that someday I may do actual work with Squiffy or Twine.

I've cached a copy of Web2Executable on my Box.com account and here on my pcloud account.

Diet tracker program

- Posted in Coding by

I've been pretty pleased with recent progress I've made on diet.exe, a console program I'm developing to help make tracking my diet easier. As of today's date, the software can synchronize diet files between Dropbox and Zim. As an added benefit, when it does this, it also synchronizes blood pressure readings between those two directories. Sweet!

I've downloaded a couple of solo gaming systems I want to read and perhaps take on a test-drive: World of Dungeons is one, Notequest the other. I have a feeling that my myth-weavers game may be in it's death throes. One player bowed out, albeit gracefully. I must admit, my own interest has begun to flag. We're at a natural point for an ending, as the party has saved Slaytonthorpe from a group of bandits who appear to be working for a much more sinister (and currently unknown) force.


I've read through the pdf for Notequest and I'm intrigued. I may look into getting the Expanded World pdf. I'm going to continue reading The Solo Adventurer's Toolkit by Paul Bimler. I may wind up using it with Black Streams, which would allow me to use the wealth of OSR and 5e adventure modules I have.

Programmatically open a command prompt or Explorer window

- Posted in Coding by

To open a command prompt:

start cmd.exe /k cd C:\Users\kyrat\Dropboxcs_dev

To instead open an Explorer window there:

START C:\Users\kyrat\Dropboxcs_dev

Compressing to and decompressing from zip archive

- Posted in Coding by

This is non-trivial, but at some point in the past I looked into compressing and decompressing programmatically using C#:

I've hosted the source code on GitHub demonstrating using .NET to compress a folder and its contents into a single .zip archive. It also demonstrates decompressing such an archive into its component directory, subdirectories, and files.

And here are a couple libraries you'll need to use: /r:System.IO.Compression.dll /r:System.IO.Compression.FileSystem.dll

Zip from the Windows command line

- Posted in Coding by

If a valid subdirectory is passed in as an argument on the command-line, will zip it to .zip file that is located in same directory as executing code:

download sourcecode

Page 3 of 7