Thursday, August 29, 2019

Get the date when a file was last modified in C#!

using System;
using System.Collections.Generic;
using System.IO;
namespace FileCrawling
{
   class Program
   {
      static void Main(string[] args)
      {
         Dictionary<string, DateTime> dictionary = new Dictionary<string, DateTime>();
         string whereAmI = @"C:\\DummyDirectory\";
         foreach (string filePath in Directory.GetFiles(whereAmI))
         {
            string fileName = filePath.Replace(whereAmI, "");
            DateTime modifiedDate = File.GetLastWriteTime(filePath);
            dictionary.Add(fileName,modifiedDate);
         }
         Console.Write("Files:\r\n");
         foreach (KeyValuePair<string, DateTime> keyValuePair in dictionary)
         {
            Console.Write(keyValuePair.Key + " unalt since " + keyValuePair.Value + "\r\n");
         }
         Console.WriteLine("\r\nPress any key to end.");
         Console.ReadKey(true);
      }
   }
}

 
 

Note that this will not crawl subfolders for files. Use Directory.GetDirectories for that per: this

Automatically close the console when debugging stops

Check the checkbox for "Automatically close the console when debugging stops" under Debugging under Options under Tools in Visual Studio 2019 to Automatically close the console when debugging stops. As of Visual Studio 2019 the console app will kind of sit open after you stop debugging and wait for you to press the return key.

Icons in Angular Material

See: this. And use this stuff like so:

<mat-icon>lock</mat-icon>

 
 

The key you fish out from the link I provide goes inside of the tag, get it? In this case I want to show the icon of a padlock so the word "lock" goes side of the mat-icon tag. You have to have Angular Materials installed within your Angular application to get this stuff afloat.

The 1903 update for Windows 10 would include kaomoji which is some further type of emoji support.

There are all sorts of bugs and errors in this thing. It is fat. The windows update from yesterday supposedly closed a lot of security holes.

Wednesday, August 28, 2019

Type "Firewall" at the start menu in Windows 10...

...to find "Firewall & network protection" which you should click on to open up "Windows Security" and hopefully therein see "Domain network (active)" and "Firewall is off." which means you are not blocking yourself.

Explore FileTable Directory

This option in the "Object Explorer" in SSMS under FileTables under Tables under a particular database should let you browse a pseudofileshare where you may tuck away files to.

Tuesday, August 27, 2019

How do I unit test router.navigate(['/elsewhere']); in an Angular app?

You use the RouterTestingModule trick like so:

import { async, ComponentFixture, TestBed } from '@angular/core/testing';
import { RealComponent } from './real.component';
import { RouterTestingModule } from '@angular/router/testing';
import { StubComponent } from './stub.component';
describe('RealComponent', () => {
   let component: RealComponent;

   let fixture: ComponentFixture<RealComponent>;
   beforeEach(async(() => {
      TestBed.configureTestingModule({
         imports: [
            RouterTestingModule.withRoutes([
               {
                  path: 'elsewhere',
               component: StubComponent
               }
            ])
         ],
         declarations: [ RealComponent, StubComponent ]
      })
      .compileComponents();
   }));
   
   beforeEach(() => {
      fixture = TestBed.createComponent(RealComponent);
      component = fixture.componentInstance;
      fixture.detectChanges();
   });
   
   it('should create', () => {
      expect(component).toBeTruthy();
   });
});

 
 

StubComponent better be damn simple:

import { Component } from '@angular/core';
@Component({
   selector: 'stub',
   template: 'n/a'
})
export class StubComponent {
   constructor() {
   
   }
}

 
 

StubComponet likely needs to be ceremonially called out in one of your real modules too and not just the pseudo, on-the-fly "module" inside the test as if it is not mentioned somewhere as a reference it may break your production build.