As an additional answer (or to compound on the existing answers) you could write an extension method to accomplish this for you within the DirectoryInfo class. Here is a sample that I wrote fairly quickly that could be embellished to provide directory names or other criteria for modification, etc:
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;
namespace DocumentDistributor.Library
{
public static class myExtensions
{
public static string[] GetFileNamesWithoutFileExtensions(this DirectoryInfo di)
{
FileInfo[] fi = di.GetFiles();
List<string> returnValue = new List<string>();
for (int i = 0; i < fi.Length; i++)
{
returnValue.Add(Path.GetFileNameWithoutExtension(fi[i].FullName));
}
return returnValue.ToArray<string>();
}
}
}
Edit: I also think this method could probably be simplified or awesome-ified if it used LINQ to achieve the construction of the array, but I don't have the experience in LINQ to do it quickly enough for a sample of this kind.
Edit 2 (almost 4 years later): Here is the LINQ-ified method I would use:
public static class myExtensions
{
public static IEnumerable<string> GetFileNamesWithoutExtensions(this DirectoryInfo di)
{
return di.GetFiles()
.Select(x => Path.GetFileNameWithoutExtension(x.FullName));
}
}