Thursday, May 29, 2008

Renaming "Form1"

Visual Studio should really allow you to change the name of the startup form on creation of a new project, or at least have a more descriptive name, such as (ProjectName)Main. However, they don't do this, and you're stuck with the entirely bland and nondescript Form1.

There is a way around this though: it's still much easier to do this right after you create the project rather than a long time down the road, but here it is:

-Rename the filename of the main form (Form1.cs, Form1.h, etc).
-Press Ctrl+H (brings up Quick Replace menu)
-Change "Look in" to "Entire Solution" (not just that file)
-Find "Form1", replace with the new name you've chosen.

Tuesday, May 27, 2008

Recurse directories with C#

I'm working on a C# program that recurses through directories, adding all the files to a list (I felt like trying out C#, and this was a good place to start). I found this VB.NET program doing something very similar, and adapted it to C#.

private void recurseDirs(String rootdir) {
DirectoryInfo dirinfo = new DirectoryInfo(rootdir);
foreach(FileInfo fi in dirinfo.GetFiles()){
FileList.Items.Add(fi.FullName);
}
foreach(DirectoryInfo di in dirinfo.GetDirectories()){
recurseDirs(di.FullName);
}
}

Friday, May 16, 2008

wget, and HTTP passwords

So, it turns out that wget has support for passworded HTTP files. It doesn't prompt by default like most browsers do; it just gets the 401 error code. However, using the options "--user=username" or "--http-user=username" and "--password=pass" or "--http-password=pass", you can get files hidden behind these user:pass mechanisms.