Quantcast
Channel: VBForums - Mobile Development
Viewing all articles
Browse latest Browse all 96

How to Download the a Video,Audio, PDF, etc into a Local Storage

$
0
0
Good Day All

i have some video and Audio Files that i would like the user to download to the Local Storage and after being downloaded it must be viewed.i tried the following code.

Code:

  string m_Url = "http://media.lakewood.org.edgesuite.net/JOM/podcast/mp3_audio/596_Podcast.mp3";//string.Empty;
       
        private void btnDownload_Click(object sender, RoutedEventArgs e)
        {
            Button button = sender as Button;
            if (button.Tag.ToString() != string.Empty)
            {

              //  m_Url = button.Tag.ToString();

                //Obtain a virtual store for application
                IsolatedStorageFile fileStorage = IsolatedStorageFile.GetUserStoreForApplication();

                if (!fileStorage.DirectoryExists("BOOKS"))
                {
                    //Create new subdirectory
                    fileStorage.CreateDirectory("BOOKS");
                }

                //Create a new StreamWriter, to write the file to the specified location.
                StreamWriter fileWriter = new StreamWriter(new IsolatedStorageFileStream("BOOKS\\" + GenericFunctions.GetFileNameinURL(m_Url), FileMode.OpenOrCreate, fileStorage));

                fileWriter.Close();

                if (fileStorage.FileExists("BOOKS\\" + GenericFunctions.GetFileNameinURL(m_Url)))
                {
                    MessageBox.Show("Download Complete");

                    GenericFunctions.PlaySound("BOOKS\\" + GenericFunctions.GetFileNameinURL(m_Url));
                }
            }
           
        }

Thanks

Viewing all articles
Browse latest Browse all 96

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>