Advertisement
svephoto

Extract File [C#]

Nov 22nd, 2019
911
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. using System;
  2.  
  3. namespace ExtractFile
  4. {
  5. class Program
  6. {
  7. static void Main(string[] args)
  8. {
  9. string pathToAFile = Console.ReadLine();
  10.  
  11. int startingIndexOtTheFileName = pathToAFile.LastIndexOf('\\');
  12. int endingIndexOtTheFileName = pathToAFile.IndexOf('.');
  13.  
  14. string fileName = pathToAFile.Substring(startingIndexOtTheFileName + 1, endingIndexOtTheFileName -
  15. startingIndexOtTheFileName - 1);
  16. string extension = pathToAFile.Substring(endingIndexOtTheFileName + 1);
  17.  
  18. Console.WriteLine($"File name: {fileName}");
  19. Console.WriteLine($"File extension: {extension}");
  20. }
  21. }
  22. }
Advertisement
Advertisement
Advertisement
RAW Paste Data Copied
Advertisement