SPIDVerificationAPI_WPF_Sample.IsolatedStorageHelper.readValue C# (CSharp) Method

readValue() public method

Reads a value from a given file
public readValue ( string filename ) : string
filename string The file to read the value from
return string
        public string readValue(string filename)
        {
            using (IsolatedStorageFile isoStore = IsolatedStorageFile.GetStore(IsolatedStorageScope.User | IsolatedStorageScope.Assembly, null, null))
            {
                try
                {
                    using (var iStream = new IsolatedStorageFileStream(filename, FileMode.Open, isoStore))
                    {
                        using (var reader = new StreamReader(iStream))
                        {
                            return reader.ReadLine();
                        }
                    }
                }
                catch (FileNotFoundException)
                {
                    return null;
                }
            }
        }
        /// <summary>

Usage Example

Example #1
0
        /// <summary>
        /// Initialize the speaker information
        /// </summary>
        private async void initializeSpeaker()
        {
            IsolatedStorageHelper _storageHelper = IsolatedStorageHelper.getInstance();
            string _savedSpeakerId = _storageHelper.readValue(MainWindow.SPEAKER_FILENAME);

            if (_savedSpeakerId != null)
            {
                _speakerId = new Guid(_savedSpeakerId);
            }
            record.IsEnabled = false;
            if (_speakerId == Guid.Empty)
            {
                bool created = await createProfile();

                if (created)
                {
                    refreshPhrases();
                }
            }
            else
            {
                setStatus("Using profile Id: " + _speakerId.ToString());
                refreshPhrases();
                string enrollmentsStatus = _storageHelper.readValue(MainWindow.SPEAKER_ENROLLMENTS);
                if ((enrollmentsStatus != null) && (enrollmentsStatus.Equals("Done")))
                {
                    resetBtn.IsEnabled = true;
                }
            }
        }
All Usage Examples Of SPIDVerificationAPI_WPF_Sample.IsolatedStorageHelper::readValue