Advertisement
Spocoman

03. Extract File

Apr 15th, 2023
734
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.47 KB | None | 0 0
  1. using System;
  2. using System.Linq;
  3. using System.Collections.Generic;
  4. using System.Text;
  5.  
  6. namespace ExtractFile
  7. {
  8.  
  9.     class Program
  10.     {
  11.         static void Main()
  12.         {
  13.             string filePath = Console.ReadLine();
  14.  
  15.             var fileInfo = filePath
  16.                 .Substring(filePath.LastIndexOf("\\") + 1)
  17.                 .Split('.');
  18.  
  19.             Console.WriteLine($"File name: {fileInfo[0]}\nFile extension: {fileInfo[1]}");
  20.         }
  21.     }
  22. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement