Friday, February 15, 2008

Add "Copy to" to Windows context menu

To enable a Copy To Folder option in the right-click menu when right-clicking a file or folder you have to add one key to the Registry. Use Windows R to open the run dialog and enter regedit in there. Now navigate to the Registry key HKEY_CLASSES_ROOT \AllFilesystemObjects \shellex \ContextMenuHandlers. You will notice the Send To entry there. Right-click the ContextMenuHandlers entry and select New > Key from the list.

Name that key Copy To and click ok. Now double-click the default entry on the left pane and give it the value {C2FBB630-2971-11D1-A18C-00C04FD75D13}.



Sunday, February 10, 2008

C# - Get Windows Profile path

Environment.GetFolderPath (Environment.SpecialFolder.UserProfile)


Saturday, February 2, 2008

Using WinSCP With iPod Touch

First make sure you have ssh and bsd subsystem installed from installer. Next get WinSCP and find your iPods ip by going to (on your iphone) settings > Wi-Fi > “Your selected WiFi” > Look under IP Address-

Connect to your iPod using WinSCP

(user: root password: alpine)

Change File Protocol to SCP


Just press login after your screen on WinScp

click on the “..” until you see root, then click on the applications folder and put your downloaded .app program inside by dragging and dropping.



To set file permissions(CHMOD) right click on the folder or file and select properties. Most of the time you will have to change the Octal to 0755.



Friday, February 1, 2008

Debugger variable $exception

If your catch block do nothing with caught exception you may declare block argument without name (to avoid warning message "CS0168: The variable 'ex' is declared but never used"):





catch (Exception)


// deliberately suppressing all exceptions


But one day during debugging you may actually want to examine Exception. Since you don't have variable where exception is stored you can use debugger variable $exception provided by the Visual Studio.NET 2005 Debugger to examine the exception in a catch block. Just add it to Watch Window.



Consider using System.IO.Path.Combine() instead of string concatenation

Let's review the following code for creating a file path:

public string GetFullPath(string fileName)
      string folder = ConfigurationManager.
AppSettings["MyFolder"]; return folder + fileName; }

This code is prone to error. For example, when you set the folder setting, you have to remember to make sure it ends with a slash. To avoid such problems use Path.Combine() method which will ensure that the folder has ending slash:

public string GetFullPath(string filename)
     string folder = ConfigurationManager.
AppSettings["MyFolder"]; return Path.Combine(folder, filename); }


Use Path.GetRandomFileName() or Path.GetTempFileName() when working with temp files

Do not reinvent function for generating unique name for temporary files. Use one of the existing methods:



Conditional breakpoints in Visual Studio

You can specify a breakpoint condition which will be evaluated when a breakpoint is reached. The debugger will break only if the condition is satisfied.

To specify a condition:

  1. In a source window, right-click a line containing a breakpoint glyph and choose Condition from Breakpoints in the shortcut menu. Conditional Breakpoint
  2. In the Breakpoint Condition dialog box, define a boolean condition using the code in your local scope. For example, you can only break when _culture != "en-US".
  3. Choose Is true if you want to break when the expression is satisfied or Has changed if you want to break when the value of the expression has changed.
  4. Click OK.