使用简单的字符串方法,如Split和System.IO.Path类:var filesAndFolders = files.Select(fn => new{ File = fn, Dir = Path.Combine(@"C:\PATH", Path.GetFileNameWithoutExtension(fn).Split('_')[0].Trim())});如果要创建该文件夹并添加文件:foreach (var x in filesAndFolders){ Directory.CreateDirectory(x.Dir); // will only create it if it doesn't exist yet string newFileName = Path.Combine(x.Dir, x.File); // we don't know the old path of the file so i can't show how to move}