Author Archives: nosajhpled

C# – Extract filename from a full path

Over the years extracting the filename from a full path has always been a pain for me. Working with C#, I discovered a one line, easy to use, solution. FileName = FileName.Split(‘\\’)[FileName.Split(‘\\’).Count() – 1]; Filename = “c:\TextFile.txt” Will return: “TextFile.txt” And FileName = (FileName.Split(‘\\’)[FileName.Split(‘\\’).Count() – 1]).Split(‘,’)[0]; Filename = “c:\TextFile.txt” Will return: “TextFile”

Two ways to fake a SQL table [SQL]

The first way is to create a temporary table and insert values into it. DECLARE @declareTable TABLE (seq int, name VARCHAR(5) ) ; INSERT INTO @declareTable (seq,name) values (1,’one’), (2,’two’), (3,’three’) select * from @declareTable as dt; The second way is to create the values inside the select statement. select * from (values (1,’one’), (2,’two’),… Read More »

Convert FoxPro to Microsoft SQL Server

The easiest way to convert FoxPro to Microsoft SQL Server is to copy the FoxPro file to a CSV and use the SQL Server Import and Export Wizard. In FoxPro use NameOfFile (or ?) copy to NameOfFile type csv This will give you a clean CSV with a header line.

Simple Log4Net Install and Usage

Click Project -> Mange NuGet Packages Choose NuGet in Package Source. Search for Log4Net Choose Log4Net and Install Add one line to Project->Properties->AssemblyInfo.cs. This line will path to the Log4Net.xml config file. [assembly: log4net.Config.XmlConfigurator(ConfigFile = “log4net.xml”, Watch = true)] Add new xml item to the project called log4net.xml (or whatever you called it above) Here… Read More »