Пример #1
0
        private File CreateImageFile()
        {
            string ImageFileName    = "JPEG_" + DateTime.Now.ToString();
            File   StorageDirectory = Environment.GetExternalStoragePublicDirectory(Environment.DirectoryPictures);
            File   Image            = File.CreateTempFile(ImageFileName, ".jpg", StorageDirectory);

            CurrentPhotoPath = Image.AbsolutePath;
            return(Image);
        }
Пример #2
0
        /// <summary>
        /// Copies the audio data to a temporary file, so the media player can play this.
        /// </summary>
        /// <param name="audio">The audio object which data should be copied.</param>
        /// <returns>The string to the file path.</returns>
        private string CopyAudioToTemp(Audio audio)
        {
            var filepath = "";

            try
            {
                string tempFileName = "temp_" + DateTime.Now.ToString("yyyy_MM_dd_HH_mm_ss");
                var    tempMp3      = File.CreateTempFile(tempFileName, ".mp3", new File(Path.GetTempPath()));
                tempMp3.DeleteOnExit();
                var fos = new FileOutputStream(tempMp3);
                fos.Write(audio.Data);
                fos.Close();
                filepath = tempMp3.AbsolutePath;
            }
            catch (IOException ioe)
            {
                Log.Warn("AndroidMediaPlayer", "Could not write audio to temp file, exception message:" + ioe.Message);
            }
            return(filepath);
        }