专注收集记录技术开发学习笔记、技术难点、解决方案
网站信息搜索 >> 请输入关键词:
您当前的位置: 首页 > Windows Mobile

无法保存文件名,该如何处理

发布时间:2010-05-30 00:18:04 文章来源:www.iduyao.cn 采编人员:星星草
无法保存文件名
using System;
using System.Collections.Generic;
using System.Linq;
using System.Net;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Navigation;
using Microsoft.Phone.Controls;
using Microsoft.Phone.Shell;
using 网络音频播放.Resources;
using System.Xml.Linq;
using System.IO.IsolatedStorage;
namespace 网络音频播放
{
    public partial class MainPage : PhoneApplicationPage
    {
        // 构造函数
        public MainPage()
        {
            InitializeComponent();
            RefreshIsoFiles();
            // 用于本地化 ApplicationBar 的示例代码
            //BuildLocalizedApplicationBar();
        }

        //刷新播放的历史记录
        private void RefreshIsoFiles()
        {
            string[] fileList;
            //读取程序中独立储存的文件名
            using (var store = IsolatedStorageFile.GetUserStoreForApplication())
            {
                fileList = store.GetFileNames();
            }
            //将文件名绑定到ListBox上
            listBox1.ItemsSource = fileList;
        }
        
        //保存播放的历史记录
        private void savehistory()
        {
            //使用音频的uri地址作为文件名
            string fileName=System.IO.Path.GetFileName(MP3Uri.Text);
            using (var store=IsolatedStorageFile.GetUserStoreForApplication())
            {
                if (!store.FileExists(fileName))
                { //创建独立储存文件
                    //IsolatedStorageFileStream file = store.CreateFile(fileName);
                    IsolatedStorageFileStream file = new IsolatedStorageFileStream(fileName, System.IO.FileMode.Create, store);
                }
            }
            //刷新播放的历史记录
            RefreshIsoFiles();
        }

        private void play_Click(object sender, RoutedEventArgs e)
        {
           // try
            //{
                if (!string.IsNullOrEmpty(MP3Uri.Text))
                {
                    media.Source = new Uri(MP3Uri.Text, UriKind.Absolute);
                    media.Play();
                    savehistory();
                }
                else
                    MessageBox.Show("请输入mp3的网络地址!");

                /*
            }
            catch (Exception)
            {
友情提示:
信息收集于互联网,如果您发现错误或造成侵权,请及时通知本站更正或删除,具体联系方式见页面底部联系我们,谢谢。

其他相似内容:

热门推荐: