limonchesled

03. Extract File2

Mar 7th, 2024
111
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.73 KB | None | 0 0
  1. namespace _03._Extract_File2
  2. {
  3. internal class Program
  4. {
  5. static void Main(string[] args)
  6. {
  7. string inputLine = Console.ReadLine();
  8.  
  9. string[] fileNameAndExtention = GetFileName(inputLine).Split('.').ToArray();
  10. Console.WriteLine("File name: " + fileNameAndExtention[0]);
  11. Console.WriteLine("File extension: " + fileNameAndExtention[1]);
  12. }
  13.  
  14. static string GetFileName(string input)
  15. {
  16. string rezult;
  17. int nameStartIndex = input.LastIndexOf('\\') + 1;
  18.  
  19. rezult = input.Substring(nameStartIndex, input.Length - nameStartIndex);
  20. return rezult;
  21. }
  22.  
  23.  
  24. }
  25. }
  26.  
Advertisement
Add Comment
Please, Sign In to add comment