Advertisement
petyaminkova91

Untitled

Nov 17th, 2019
116
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.73 KB | None | 0 0
  1. using System;
  2.  
  3. namespace _03_ExtractFile
  4. {
  5. class ExtractFile
  6. {
  7. static void Main(string[] args)
  8. {
  9. string directory = Console.ReadLine();
  10.  
  11. int indexOfDot = directory.IndexOf('.');
  12. string extension = directory.Substring(indexOfDot + 1);
  13. int extensionLength = extension.Length;
  14.  
  15. int lastIndexOfSlash = directory.LastIndexOf('\\');
  16. int fileNameLenth = directory.Length - extensionLength - lastIndexOfSlash - 2;
  17. string fileName = directory.Substring(lastIndexOfSlash + 1, fileNameLenth);
  18.  
  19. Console.WriteLine($"File name: {fileName}");
  20. Console.WriteLine($"File extension: {extension}");
  21. }
  22. }
  23. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement