Posts

Showing posts from October, 2018

Removing duplicate lines in a text file using notepad++

Image
First ensure the TextFx plugin has been installed in your version of notepad++. Some example text: I then copy and paste that block of text to ensure there are duplicate lines: Removing the duplicates involves THREE steps: 1. If you have not already done so, ensure the appropriate TextFX plugin is checked. Select TextFX > TextFX Tools > Sort outputs only UNIQUE at column lines: 2. Select ALL of your text (select Control + A) 3. Select TextFX > TextFX Tools > Sort lines case sensitive (at column): See that the duplicate lines have been identified and removed:

Using robocopy to transfer files: tips and tricks

Image
1. To copy a single file [code language="xml"] robocopy c:\this_folder d:\that_folder file.txt [/code]   2. To copy multiple files [code language="xml"] robocopy c:\this_folder d:\that_folder file1.txt file2.txt [/code]   3. To copy all files of a given extension [code language="xml"] robocopy c:\this_folder d:\that_folder *.txt [/code]   4. To copy the contents of an entire directory Robocopy creates the d:\that_folder\a directory and copies the files from the c:\this_folder\a directory into it. Use the E/ switch to copy the entire directory tree under c:\this_folder\a [code language="xml"] robocopy c:\this_folder\a d:\that_folder\a /E [/code]   5. To exclude existing files from the copy A really good tip taken from this GitHub link : This can save a lot of time particularly if you have to copy many large sized files. [code language="xml"] robocopy c:\this_folder d:\that_folder /E /XC /XN /XO [/code] /E - ...

How to remove lines containing specific text in Notepad++ using the Bookmarks method

Image
How to use Notepad++ to remove all lines containing a specific text. First install Notepad++ if you have not already done so, given that it really is a powerful piece of software: https://notepad-plus-plus.org/download/ Now we can demonstrate an example with the following XML-style text: Suppose we wish to remove all lines containing the text "wpdm" To do this select Control+F to fire up the Find dialog. Select the Mark tab, enter the text you wish to search for and make sure the Bookmark line checkbox is set: Select the Mark all button and close the dialog. Observe that all lines containing "wpdm" are bookmarked: To remove the bookmarked lines, select Search > Bookmarks > Remove bookmarked lines: So that the bookmarked lines are removed as shown:

How to programmatically control access to files in C# using FileSecurity objects

Image
A quick demonstration on how to control access to files in real-time. As described in the Microsoft documentation , the control access to a file can be added or removed by obtaining the FileSecurity object from that file, then modified, and then applied back to the file. In this example I choose to change the file access properties of a simple icon file "icon.ico": So that before modifying the properties it can be opened straightforwardly as follows: To demonstrate how we can alter the access properties in real-time, create a C# console application in Visual Studio and add the following code. Note the use of WindowsIdentity.GetCurrent() api used to obtain the necessary username/domain details of the current Windows user: [code language="csharp"] using System; using System.IO; using System.Security.AccessControl; using System.Security.Principal; namespace FileControlAccess { class Program { static void Main(string[] args) { ...