.NET Code To Set OpenFileDialog Initial Folder With a String

by jason18. July 2006 12:37

This code uses a string to set the initial folder of an OpenFileDialog.

class Test
{
const string MyComputer = "::{20D04FE0-3AEA-1069-A2D8-08002B30309D}";
const string MyDocuments  = "::{450D8FBA-AD25-11D0-98A8-0800361B1103}";
const string MyNetworkPlaces = "::{208D2C60-3AEA-1069-A2D7-08002B30309D}";
const string Printers = "::{2227A280-3AEA-1069-A2DE-08002B30309D}";
const string RecycleBin = "::{645FF040-5081-101B-9F08-00AA002F954E}";
const string Tasks = "::{D6277990-4C6A-11CF-8D87-00AA0060F5BF}";
[STAThread]
static void Main(string[] args)
{
OpenFileDialog ofd = new OpenFileDialog();
ofd.InitialDirectory = MyComputer;
ofd.ShowDialog();
}
}

Tags:

Development

About

Jason Williams is a .NET developer in Lincoln, Nebraska.

The name "Centrolutions" came out of a long search for a domain name. The goal was to create a name that conveyed an ideology of writing software centered (Centr--) on a solution (--olutions) for a particular problem. In other words, it was the only name in a long list that wasn't already registered on the internet.

If you're looking for the products I have for sale, you should go here.