locked
Windows 8.1 Store App using Visual Studio 2013 professional and Visual Basic

    Question

  • You cannot vote on your own post         

    Hi,

    I am trying to develop a simple Windows 8.1 Store App using Visual Studio 2013 professional and Visual Basic as a programming language. I have the following problem:

    I would like in runtime to be able to access the list of the file names within the application's assets subfolder (say "/WordPictures" as in the attached image) and manipulate / choose a file based on a certain criteria. I know how to do it for Windows desktop application, however here it is different.

    Any help regarding this will be very much appreciated.

    Thanks

    Miho Mihov

    Friday, March 13, 2015 2:34 AM

Answers

  • Try this code. I haven't checked it, but it's automatically converted from my C# code in to VB. It should be close to what you need:

    Public Function GetFileListFromFolder() As Task(Of List(Of String)) Dim fileList As New List(Of String)() Dim storageFolder As StorageFolder = Await Package.Current.InstalledLocation.GetFolderAsync("myFolder\") For Each fl As StorageFile In Await storageFolder.GetFilesAsync() fileList.Add(fl.Name) Next Return fileList End Function

    That returns a string list of all files in the given folder.


    I'm a self-taught noob amateur. Please take this into account when responding to my posts or when taking advice from me.


    Friday, March 13, 2015 7:00 AM

All replies

  • This question is a bit broad for a forum post. What have you tried and where does it fail? This code will give a list of files in an app folder. It might get you started: [c# code, but should be easy to translate to VB]
    public async Task<List<string>> GetFileListFromFolder() {   
        List<string> fileList = new List<string>();
        StorageFolder storageFolder = await Package.Current.InstalledLocation.GetFolderAsync(@"myFolder\");
    
        foreach (StorageFile fl in await storageFolder.GetFilesAsync())
        {
           fileList.Add(fl.Name);
        } 
        return fileList; 
    }


    I'm a self-taught noob amateur. Please take this into account when responding to my posts or when taking advice from me.


    • Edited by pumpkinszwan Friday, March 13, 2015 6:59 AM formatting
    Friday, March 13, 2015 6:25 AM
  • Thanks for your reply. All I want to achieve is obtain the file list in the assets subfolder and assign it to a one dimensional string array. Then I will search that array based on information entered by the user and then use that file as a source for MediaElement or Image eventually.

    Unfortunately I am not familiar with C#. I will be searching a bit more and maybe someone will help me along the way.

    Thank you for your time.

    Miho

     

    Friday, March 13, 2015 6:52 AM
  • Try this code. I haven't checked it, but it's automatically converted from my C# code in to VB. It should be close to what you need:

    Public Function GetFileListFromFolder() As Task(Of List(Of String)) Dim fileList As New List(Of String)() Dim storageFolder As StorageFolder = Await Package.Current.InstalledLocation.GetFolderAsync("myFolder\") For Each fl As StorageFile In Await storageFolder.GetFilesAsync() fileList.Add(fl.Name) Next Return fileList End Function

    That returns a string list of all files in the given folder.


    I'm a self-taught noob amateur. Please take this into account when responding to my posts or when taking advice from me.


    Friday, March 13, 2015 7:00 AM