-2

How to get extension file from local folder? I have many file on library folder on the package

BookAudio Class:

class BookAudio
    {
        public string Name { get; set; }
    }

I mean is not on drive E:\ or another, but in a package folder "Library". code: StorageFolder library = await installedLocation.CreateFolderAsync ("library", CreationCollisionOption.OpenIfExists); And I want to take the extension into if, for example: if the extension pdf, then navigate to the page pdfView.

Rose
  • 613
  • 4
  • 22
  • 1
    Possible duplicate of [How to find extension of a file?](http://stackoverflow.com/questions/1886866/how-to-find-extension-of-a-file) – Yahya Jun 02 '16 at 09:19
  • If you want to get the file name extension of a file in UWP, you can use [StorageFile.FileType property](https://msdn.microsoft.com/en-us/library/windows/apps/windows.storage.storagefile.filetype.aspx). – Jay Zuo Jun 03 '16 at 07:50

1 Answers1

1

try this Path.GetExtension Method (String)

string ext = Path.GetExtension("FilePath");

Or you can simply use this

string PathTofile = @"E:\POSAPP\POS\POS\bin\Debug\kjhs.exe";
string extension = PathTofile.Substring(PathTofile.LastIndexOf('.')+1, PathTofile.Length - PathTofile.LastIndexOf('.')-1);
Manu Varghese
  • 791
  • 8
  • 25
  • I mean is not on drive E: \ or another, but in a package folder "Library". code: StorageFolder library = await installedLocation.CreateFolderAsync ("library", CreationCollisionOption.OpenIfExists); And I want to take the extension into if, for example: if the extension pdf, then navigate to the pdfView page. – Rose Jun 03 '16 at 01:20