Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Text;
- namespace ExtractFile
- {
- class MainClass
- {
- public static void Main(string[] args)
- {
- string text = Console.ReadLine();
- int startIndexFileName = text.LastIndexOf('\\') + 1;
- int endIndexFileName = text.LastIndexOf('.');
- int fileNameLength = endIndexFileName - startIndexFileName;
- string fileName = text.Substring(startIndexFileName, fileNameLength);
- int startIndexExtension = text.LastIndexOf('.')+1;
- string extension = text.Substring(startIndexExtension);
- Console.WriteLine($"File name: {fileName}");
- Console.WriteLine($"File extension: {extension}");
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement