Advertisement
Guest User

Extract File c#

a guest
Nov 22nd, 2019
666
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.51 KB | None | 0 0
  1. using System;
  2.  
  3. namespace String_Explosions
  4. {
  5.     class Program
  6.     {
  7.         static void Main(string[] args)
  8.         {
  9.               string[] input = Console.ReadLine().Split("\\\\");
  10.               string file = input[input.Length - 1];  
  11.  
  12.             string fileName = file.Substring(0, file.LastIndexOf("."));
  13.             string fileExtension = file.Substring(file.LastIndexOf('.') + 1);
  14.             Console.WriteLine($"File name: {fileName} \nFile extension: {fileExtension}");
  15.  
  16.  
  17.         }
  18.  
  19.  
  20.        
  21.     }
  22. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement