Call us: (206) 905-4626
Bellevue, WA
 

Knowledge Base

Copying file progress

In .NET Framework there is no functionality for visual display of file copying process using ProgressBar. To obtain this functionality it is necessary to import Windows API function CopyFileEx. CopyFileEx allows defining function reference for system in case of copying file. To make usage of this function more comfortable CopyFileHandler class was created. CopyFileHandler class can be found in ShowCopyProgress.cs file. Also in this file delegates, constants and event argument class are defined. A simple application was created to demonstrate usage of this class. Application allows to choose file and to copy it to the target directory. During copying window with progress bar is displaying; the window contains Cancel button which cancel copying if pressed. Visual Studio 2003 is necessary to build the application.

Shutdown helper

This source code demonstrates how to perform computer Restart/Shutdown/Logoff from the .NET Framework application using Windows API functions. We use the Windows API functions because there is no appropriate functionality in .NET Framework. The file ExitSystem.cs includes classes, which are necessary to perform system Restart/Shutdown/Logoff. This functionality is implemented as a wrapper of appropriate Win 32 API functions as ExitWindowsEx. Flag values of this function could be found in MSDN. Visual Studio 2003 is necessary to build the application.

Managed wrapper for Win32 Semaphore

.Net Framework v. 1.x. does not contain class with functionality object Semaphore. This example shows the simple implementation of this class. User of class can:

  1. Create new Semaphore
  2. Open specified Semaphore
  3. Increase Semaphore counter
  4. Decrease Semaphore counter

Semaphore class is created as an inheritor on System.Threading.WaitHandle class. As a result there is the wrapper for those Windows API functions: CreateSemaphore, OpenSemaphore, ReleaseSemaphore, WaitForSingleObject.