Register Register Member Login Member Login Member Login Forgot Password ??
PHP , ASP , ASP.NET, VB.NET, C#, Java , jQuery , Android , iOS , Windows Phone
 

Registered : 109,027

HOME > Mobile > Windows Phone Dev - สอนเขียน App บนโปรแกรม Windows Phone 7 , Windows Phone 8 > Windows Phone List Show File In Isolated Storage (Application Storage)



Clound SSD Virtual Server

Windows Phone List Show File In Isolated Storage (Application Storage)

Windows Phone List Show File In Isolated Storage (Application Storage) บทความและตัวอย่างการเขียนโปรแกรมบน Windows Phone ในการอ่านแสดงรายชื่อไฟล์ที่อยู่ใน Isolated Storage ของ Application มาแสดงในหน้า Page ของ Application โดยในตัวอย่างนี้จะอ่านรายชื่อไฟล์ที่เป็น Text file ที่ถูกจัดเก็บไว้ก่อนหน้านี้แล้ว มีตัวอย่างทั้ง VB.NET และ C#

Windows Phone List Show File  In Isolated Storage

Windows Phone List Show File In Isolated Storage


Basic Windows Phone and Isolated Storage (Application Storage)

สำหรับพื้นฐาน Isolated Storage กับ Windows Phone ควรอ่าน 2 บทความนี้ เพื่อความเข้าใจ

Windows Phone List Show File  In Isolated Storage

เป็นรายชื่อไฟล์ที่อยู่ใน Isolated Storage ของ Application บน Windows Phone


Example ตัวอย่างการอ่านรายชื่อไฟล์ที่อยู่ใน Isolated Storage บน Windows Phone

MainPage.xaml

Windows Phone List Show File  In Isolated Storage

    <!--LayoutRoot is the root grid where all page content is placed-->
    <Grid x:Name="LayoutRoot" Background="Transparent">
        <Grid.RowDefinitions>
            <RowDefinition Height="Auto"/>
            <RowDefinition Height="*"/>
        </Grid.RowDefinitions>

        <!--TitlePanel contains the name of the application and page title-->
        <StackPanel x:Name="TitlePanel" Grid.Row="0" Margin="12,17,0,28">
            <TextBlock x:Name="ApplicationTitle" Text="MY APPLICATION" Style="{StaticResource PhoneTextNormalStyle}"/>
            <TextBlock x:Name="PageTitle" Text="page name" Margin="9,-7,0,0" Style="{StaticResource PhoneTextTitle1Style}"/>
        </StackPanel>

        <!--ContentPanel - place additional content here-->
        <StackPanel x:Name="ContentPanel" Grid.Row="1" Margin="12,0,12,0">

        </StackPanel>

    </Grid>









MainPage.xaml.vb (VB.NET)
Imports System.IO
Imports System.Text
Imports System.IO.IsolatedStorage

Partial Public Class MainPage
    Inherits PhoneApplicationPage

    ' Constructor
    Public Sub New()
        InitializeComponent()

        AddHandler Loaded, AddressOf MainPage_Loaded

    End Sub

    Private Sub MainPage_Loaded(sender As Object, e As System.Windows.RoutedEventArgs)

        Dim fileList As New List(Of String)

        '*** Ger all file from  Isolated Storage***'
        Dim isoStore As IsolatedStorageFile = IsolatedStorageFile.GetUserStoreForApplication() ' Path Storage
        Dim files As String() = isoStore.GetFileNames("*")
        For Each dirfile As String In files
            fileList.Add(dirfile)
        Next

        '*** Show All Files ***'
        For Each file As String In fileList
            Dim ctrlText As New TextBlock
            ctrlText.Text = file.ToString()
            ContentPanel.Children.Add(ctrlText)
        Next

    End Sub


End Class

MainPage.xaml.cs (C#)
using System;
using System.Windows;
using System.Net;
using System.IO;
using System.Text;
using System.IO.IsolatedStorage;
using Microsoft.Phone.Controls;
using Microsoft.Phone.Shell;
using System.Collections.Generic;
using System.Windows.Controls;

namespace PhoneApp
{
    public partial class MainPage : PhoneApplicationPage
    {
        // Constructor
        public MainPage()
        {
            InitializeComponent();
            Loaded += MainPage_Loaded;
        }

        private void MainPage_Loaded(object sender, System.Windows.RoutedEventArgs e)
        {
            List<string> fileList = new List<string>();

            //*** Ger all file from  Isolated Storage***'
            IsolatedStorageFile isoStore = IsolatedStorageFile.GetUserStoreForApplication();
            // Path Storage
            string[] files = isoStore.GetFileNames("*");
            foreach (string dirfile in files)
            {
                fileList.Add(dirfile);
            }

            //*** Show All Files ***'
            foreach (string file in fileList)
            {
                TextBlock ctrlText = new TextBlock();
                ctrlText.Text = file.ToString();
                ContentPanel.Children.Add(ctrlText);
            }

        }

    }

}

ในตัวอย่างนี้มี Code ทั้งที่เป็น VB.NET และ C# และสามารถดาวน์โหลด All Code ทั้งหมดได้จากส่วนท้ายของบทความ (Login สมาชิกก่อน)

Screenshot

Windows Phone List Show File  In Isolated Storage

แสดงรายชื่อไฟล์บนหน้า Page โดยในตัวอย่างจะแสดงรายการบน TextBlock ที่มีการ Create Control ขึ้นมาใหม่ และแสดงภายใต้ StackPanel








   
Share


ช่วยกันสนับสนุนรักษาเว็บไซต์ความรู้แห่งนี้ไว้ด้วยการสนับสนุน Source Code 2.0 ของทีมงานไทยครีเอท


ลองใช้ค้นหาข้อมูล


   


Bookmark.   
       
  By : ThaiCreate.Com Team (บทความเป็นลิขสิทธิ์ของเว็บไทยครีเอทห้ามนำเผยแพร่ ณ เว็บไซต์อื่น ๆ)
  Score Rating :  
  Create/Update Date : 2012-09-15 11:10:23 / 2017-03-25 22:23:58
  Download : Download  Windows Phone List Show File  In Isolated Storage (Application Storage)
 Sponsored Links / Related

 
Windows Phone and Isolated Storage (Application Storage)
Rating :

 
Windows Phone ListBox Image Binding and Resource from Isolated Storage (Application Storage)
Rating :

 
Windows Phone Play MP3 or Video MediaElement from Isolated Storage (Application Storage)
Rating :

 
Windows Phone Copy Transfer file from PC Between Isolated Storage (Application Storage)
Rating :

 
Windows Phone Download Save file to Isolated Storage (Application Storage)
Rating :

 
Windows Phone Create and Write Text File In Isolated Storage (Application Storage)
Rating :

 
Windows Phone Read Text File in Isolated Storage (Application Storage)
Rating :

 
Windows Phone Delete / Remove File In Isolated Storage (Application Storage)
Rating :

 
Windows Phone Image Source From Isolated Storage (Application Storage)
Rating :


ThaiCreate.Com Forum


Comunity Forum Free Web Script
Jobs Freelance Free Uploads
Free Web Hosting Free Tools

สอน PHP ผ่าน Youtube ฟรี
สอน Android การเขียนโปรแกรม Android
สอน Windows Phone การเขียนโปรแกรม Windows Phone 7 และ 8
สอน iOS การเขียนโปรแกรม iPhone, iPad
สอน Java การเขียนโปรแกรม ภาษา Java
สอน Java GUI การเขียนโปรแกรม ภาษา Java GUI
สอน JSP การเขียนโปรแกรม ภาษา Java
สอน jQuery การเขียนโปรแกรม ภาษา jQuery
สอน .Net การเขียนโปรแกรม ภาษา .Net
Free Tutorial
สอน Google Maps Api
สอน Windows Service
สอน Entity Framework
สอน Android
สอน Java เขียน Java
Java GUI Swing
สอน JSP (Web App)
iOS (iPhone,iPad)
Windows Phone
Windows Azure
Windows Store
Laravel Framework
Yii PHP Framework
สอน jQuery
สอน jQuery กับ Ajax
สอน PHP OOP (Vdo)
Ajax Tutorials
SQL Tutorials
สอน SQL (Part 2)
JavaScript Tutorial
Javascript Tips
VBScript Tutorial
VBScript Validation
Microsoft Access
MySQL Tutorials
-- Stored Procedure
MariaDB Database
SQL Server Tutorial
SQL Server 2005
SQL Server 2008
SQL Server 2012
-- Stored Procedure
Oracle Database
-- Stored Procedure
SVN (Subversion)
แนวทางการทำ SEO
ปรับแต่งเว็บให้โหลดเร็ว


Hit Link
   







Load balance : Server 04
ThaiCreate.Com Logo
© www.ThaiCreate.Com. 2003-2024 All Rights Reserved.
ไทยครีเอทบริการ จัดทำดูแลแก้ไข Web Application ทุกรูปแบบ (PHP, .Net Application, VB.Net, C#)
[Conditions Privacy Statement] ติดต่อโฆษณา 081-987-6107 อัตราราคา คลิกที่นี่