cadencii.cp932reader.ReadToEnd C# (CSharp) Méthode

ReadToEnd() public méthode

public ReadToEnd ( ) : string
Résultat string
        public string ReadToEnd() {
            StringBuilder sb = new StringBuilder();
            while ( Peek() >= 0 ) {
                sb.Append( ReadLine() + Environment.NewLine );
            }
            return sb.ToString();
        }

Usage Example

Exemple #1
0
    void UpdateProfile() {
        if ( Singer == "" || !Directory.Exists( Singer ) ) {
            pictSumbnail.Image = null;
            lblName.Text = "(Unknown)";
            return;
        }
        string character = Path.Combine( Singer, "character.txt" );
        if ( File.Exists( character ) ) {
            using ( cp932reader sr = new cp932reader( character ) ) {
                string line = "";
                while ( (line = sr.ReadLine()) != null ) {
                    string[] spl = line.Split( "=".ToCharArray(), 2 );
                    if ( spl.Length >= 2 ) {
                        if ( spl[0].ToLower() == "name" ) {
                            lblName.Text = spl[1];
                        } else if ( spl[0].ToLower() == "image" ) {
                            string image = Path.Combine( Singer, spl[1] );
                            if ( File.Exists( image ) ) {
                                try {
                                    pictSumbnail.Image = System.Drawing.Bitmap.FromFile( image );
                                } catch {
                                }
                            }
                        }
                    }
                }
            }
        }

        string readme = Path.Combine( Singer, "readme.txt" );
        if ( File.Exists( readme ) ) {
            using ( cp932reader sr = new cp932reader( readme ) ) {
                txtProf.Text = sr.ReadToEnd();
            }
        } else {
            txtProf.Text = "";
        }
    }