fork(5) download
  1. using System;
  2. using System.IO;
  3.  
  4. public class Test {
  5. private static string GetPathWithoutExtensions(string path) {
  6. var directoryPath = Path.GetDirectoryName(path);
  7. var baseName = Path.GetFileName(path);
  8. var baseNameWithoutExtensions = baseName.Split(new[] {'.'}, 2)[0];
  9.  
  10. return Path.Combine(directoryPath, baseNameWithoutExtensions);
  11. }
  12.  
  13. public static void Main() {
  14. Console.WriteLine(
  15. GetPathWithoutExtensions(
  16. @"C:\Users\me\Desktop\filename.This.Is.An.Extension"));
  17. }
  18. }
Success #stdin #stdout 0s 131520KB
stdin
Standard input is empty
stdout
C:\Users\me\Desktop\filename