locked
InstallationFolder.GetFileAsync can't show video file.

    Question

  • Hello I am simple List app that can show a file list in asset folder .. 

    Actually I tryied to use   InstallationFolder.GetFileAsync API 

    and i added  one .mp4 file  in asset folder but  InstallationFolder.GetFileAsync API but it  does not show  video file.

    i made a code like this .

    StorageFolder InstallationFolder = Windows.ApplicationModel.Package.Current.InstalledLocation;
    string preFile = @"Assets\" + fileName;
    StorageFile playlistFile = await InstallationFolder.GetFileAsync(preFile);

    I want to know If put into a text file and video file in asset, and would like to know of the list.

    If the asset folder  have a problem with It How can i do ?

     Thank you for answers.



    Thursday, November 27, 2014 2:57 AM

Answers

  • Hi Derrickboy,

    >> build action is set to content? What does mean?

    Please refer to the following link to see more information about build action. http://stackoverflow.com/questions/145752/what-are-the-various-build-action-settings-in-vs-net-project-properties-and-wh.

    After changing build action to Content, the following code snippet should work. Please test and let me know the result.

    StorageFolder InstallationFolder = Windows.ApplicationModel.Package.Current.InstalledLocation;
                StorageFolder AssetFolder = await InstallationFolder.GetFolderAsync("Assets");
                System.Collections.Generic.IReadOnlyList<StorageFile> fileList = null;
               fileList = await AssetFolder.GetFilesAsync();
    

    Regards,


    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place. Click HERE to participate the survey.

    Tuesday, December 02, 2014 7:45 AM
    Moderator

All replies

  • (1) How do you add .mp4 file to Assests folder ? Don't use Windows File Explorer, the file should be added by Visual Studio.

    (2) This is my sample code, it work fine

    <Page
        x:Class="GetInstallationFolderfile.MainPage"
        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
        xmlns:local="using:GetInstallationFolderfile"
        xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
        xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
        mc:Ignorable="d">
    
        <Grid Background="{ThemeResource ApplicationPageBackgroundThemeBrush}">
            <StackPanel >
                <Button Click="Button_Click" Content="get file" Margin="12,48,0,0"/>
                <TextBlock x:Name="textblock" FontSize="24"/>
            </StackPanel>
        </Grid>
    </Page>
    

    namespace GetInstallationFolderfile
    {
        /// <summary>
        /// An empty page that can be used on its own or navigated to within a Frame.
        /// </summary>
        public sealed partial class MainPage : Page
        {
            public MainPage()
            {
                this.InitializeComponent();
            }
    
           async private void Button_Click(object sender, RoutedEventArgs e)
            {
               string fileName ="W01.mp4";
                StorageFolder InstallationFolder = Windows.ApplicationModel.Package.Current.InstalledLocation;
               string preFile = @"Assets\" + fileName;
               StorageFile playlistFile = await InstallationFolder.GetFileAsync(preFile);
               if (playlistFile != null)
               {
                   textblock.Text = playlistFile.DisplayName;
               }
            }
        }
    }

     

    在現實生活中,你和誰在一起的確很重要,甚至能改變你的成長軌跡,決定你的人生成敗。 和什麼樣的人在一起,就會有什麼樣的人生。 和勤奮的人在一起,你不會懶惰; 和積極的人在一起,你不會消沈; 與智者同行,你會不同凡響; 與高人為伍,你能登上巔峰。

    Thursday, November 27, 2014 5:30 AM
  • Thanks your reply :)

    but this list app is windowphone 8.1 app ,  your app also window phone 8.1 app right? 

    I also added using the visualstudio..

    StorageFolder InstallationFolder = Windows.ApplicationModel.Package.Current.InstalledLocation;
    string preFile = @"Assets\" + fileName;
    ------> StorageFile playlistFile = await InstallationFolder.GetFileAsync(preFile);


    this is mycode..  when I break this line (-----> ) in visualstudio , I can't see a video file list. 

    I think it is seem to impossible  see  videofiles in normal folder  except of video libary folder. 

    anyway thanks.

    Saturday, November 29, 2014 8:16 AM
  • try to set breakpoint on ->  if (playlistFile != null)

    在現實生活中,你和誰在一起的確很重要,甚至能改變你的成長軌跡,決定你的人生成敗。 和什麼樣的人在一起,就會有什麼樣的人生。 和勤奮的人在一起,你不會懶惰; 和積極的人在一起,你不會消沈; 與智者同行,你會不同凡響; 與高人為伍,你能登上巔峰。

    Saturday, November 29, 2014 11:53 AM
  • HI Bill Thanks reply

    I checked . mp4 files in my list .. that's good

    but  I am curious of one thing , Is it ok if i added  .ts file in my list

    is it also can see in my list fie? 

    Thanks

    Derrick.


    Monday, December 01, 2014 5:39 AM
  • you can put there any file you want

    Microsoft Certified Solutions Developer - Windows Store Apps Using C#

    Monday, December 01, 2014 6:33 AM
  • put there  it's ok but 

    I can't see a .ts file  i did like this ,

    StorageFolder AssetFolder = await InstallationFolder.GetFolderAsync("Assets");
    				System.Collections.Generic.IReadOnlyList<StorageFile> fileList = null;
    
    
    
    fileList = await AssetFolder.GetFilesAsync();

    thanks.


    • Edited by derrickboy Monday, December 01, 2014 7:20 AM
    Monday, December 01, 2014 7:19 AM
  • fielist doesn't show the ts file?

    if you select the ts file in the solution explorer and look at the properties, build action is set to content?


    Microsoft Certified Solutions Developer - Windows Store Apps Using C#

    Monday, December 01, 2014 7:33 AM
  • build action is set to content?

    what does mean? 

    after check  properties,  Not any settings to a file.

    Do I shoud  do something ?

    Thanks


    • Edited by derrickboy Monday, December 01, 2014 8:11 AM
    Monday, December 01, 2014 8:11 AM
  • Hi Derrickboy,

    >> build action is set to content? What does mean?

    Please refer to the following link to see more information about build action. http://stackoverflow.com/questions/145752/what-are-the-various-build-action-settings-in-vs-net-project-properties-and-wh.

    After changing build action to Content, the following code snippet should work. Please test and let me know the result.

    StorageFolder InstallationFolder = Windows.ApplicationModel.Package.Current.InstalledLocation;
                StorageFolder AssetFolder = await InstallationFolder.GetFolderAsync("Assets");
                System.Collections.Generic.IReadOnlyList<StorageFile> fileList = null;
               fileList = await AssetFolder.GetFilesAsync();
    

    Regards,


    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place. Click HERE to participate the survey.

    Tuesday, December 02, 2014 7:45 AM
    Moderator
  • Thanks  got it , 

    have a nice day

    Friday, December 05, 2014 7:32 AM