System.IO.FileInfo.OpenRead C# (CSharp) Method

OpenRead() public method

public OpenRead ( ) : System.IO.FileStream
return System.IO.FileStream
        public System.IO.FileStream OpenRead() { throw null; }
        public System.IO.StreamReader OpenText() { throw null; }

Same methods

FileInfo::OpenRead ( ) : FileStream

Usage Example

Example #1
1
File: Test.cs Project: hcesar/Chess
        internal static IList<Test> LoadAll()
        {
            var file = new FileInfo("tests.xml");

            if (!file.Exists)
                return new Test[0];

            XmlDocument xml = new XmlDocument();
            using (var fs = file.OpenRead())
                xml.Load(fs);

            var ret = new List<Test>();
            foreach (XmlNode node in xml.SelectNodes("/Tests/*"))
            {
                var n = node.SelectSingleNode("./Type");

                if (n == null)
                    throw new InvalidOperationException("Test Type must be informed.");

                var typeName = n.InnerText;
                var type = FindType(typeName);

                if (type == null)
                    throw new InvalidOperationException(string.Format("'{0}' is not a valid Test.", typeName));

                var obj = (Test)Activator.CreateInstance(type);
                node.ToEntity(obj);

                ret.Add(obj);
            }

            return ret;
        }
All Usage Examples Of System.IO.FileInfo::OpenRead