当前位置: 首页>>代码示例>>C#>>正文


C# FileInfo.ReadToEnd方法代码示例

本文整理汇总了C#中System.IO.FileInfo.ReadToEnd方法的典型用法代码示例。如果您正苦于以下问题:C# FileInfo.ReadToEnd方法的具体用法?C# FileInfo.ReadToEnd怎么用?C# FileInfo.ReadToEnd使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在System.IO.FileInfo的用法示例。


在下文中一共展示了FileInfo.ReadToEnd方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: Load

 /// <summary>
 /// Loads this instance.
 /// </summary>
 /// <returns>The current plugin list</returns>
 public static PluginList Load()
 {
     string FileLocation = HttpContext.Current != null ? HttpContext.Current.Server.MapPath("~/App_Data/PluginList.txt") : AppDomain.CurrentDomain.BaseDirectory + "/App_Data/PluginList.txt";
     if (!new System.IO.FileInfo(FileLocation).Exists)
         return new PluginList();
     using (StreamReader Reader = new System.IO.FileInfo(FileLocation).OpenText())
     {
         return Deserialize(Reader.ReadToEnd());
     }
 }
开发者ID:modulexcite,项目名称:Craig-s-Utility-Library,代码行数:14,代码来源:PluginList.cs

示例2: WriteLine_Nothing

        public void WriteLine_Nothing()
        {
            csvReaderWriter.Open(TestOutputFile, CSVReaderWriter.Mode.Write);
            csvReaderWriter.WriteLine();
            csvReaderWriter.Close();

            StreamReader reader = new FileInfo(TestOutputFile).OpenText();
            Assert.That(reader.ReadToEnd(), Is.EqualTo("\r\n"));
            reader.Close();
        }
开发者ID:povilaspanavas,项目名称:HireRefactorCsvReader,代码行数:10,代码来源:CSVReaderWriterTests.cs

示例3: ReadFileUTF8

 public string ReadFileUTF8(string filePath)
 {
     string ret;
     using (var stream = new FileInfo(filePath).OpenText())
     {
         ret = stream.ReadToEnd();
         stream.Close();
     }
     return ret;
 }
开发者ID:peterson1,项目名称:ErrH,代码行数:10,代码来源:WindowsFsShim.cs

示例4: Runner

        public Runner(IRunnerSettings settings, ILogger logger = null)
        {
            if (settings == null)
                throw new ArgumentNullException("settings");

            _settings = settings;
            _logger = logger ?? new NullLogger();
            var configPath = Path.Combine(Directory.GetCurrentDirectory(), "config.json");

            using (var reader = new FileInfo(configPath).OpenText())
                _config = JsonConvert.DeserializeObject<ScriptDeployerConfig>(reader.ReadToEnd());
        }
开发者ID:nick-randal,项目名称:UsefulCSharp,代码行数:12,代码来源:Runner.cs

示例5: Map

        public Map( string _SourceFileName )
        {
            // Setup base directory for files rebasing
            ms_BaseDirectory = Path.GetDirectoryName( _SourceFileName );

            // Parse entities, models & materials
            m_Entities.Clear();
            using ( StreamReader R = new FileInfo( _SourceFileName ).OpenText() ) {
                string	Content = R.ReadToEnd();
                Parse( Content );
            }
        }
开发者ID:Patapom,项目名称:GodComplex,代码行数:12,代码来源:Map.cs

示例6: GetData

        public override IEnumerable<object[]> GetData(MethodInfo methodUnderTest,
                                                      Type[] parameterTypes)
        {
            if (null == methodUnderTest)
            {
                throw new ArgumentNullException("methodUnderTest");
            }

            if (null == parameterTypes)
            {
                throw new ArgumentNullException("parameterTypes");
            }

#if NET20
            if (Cavity.Collections.IEnumerableExtensionMethods.Count(Files) != parameterTypes.Length)
            {
                throw new InvalidOperationException(StringExtensionMethods.FormatWith(Resources.Attribute_CountsDiffer, Cavity.Collections.IEnumerableExtensionMethods.Count(Files), parameterTypes.Length));
            }
#else
            if (Files.Count() != parameterTypes.Length)
            {
                throw new InvalidOperationException(Resources.Attribute_CountsDiffer.FormatWith(Files.Count(), parameterTypes.Length));
            }

#endif

            var list = new List<object>();
            var index = -1;
            foreach (var file in Files)
            {
                var info = new FileInfo(file);
#if NET20
                var value = FileInfoExtensionMethods.ReadToEnd(info);
#else
                var value = info.ReadToEnd();
#endif
                index++;
                if (parameterTypes[index] == typeof(JObject))
                {
                    list.Add(JObject.Parse(value));
                    continue;
                }

                list.Add(JsonConvert.DeserializeObject(value, parameterTypes[index]));
            }

            yield return list.ToArray();
        }
开发者ID:KarlDirck,项目名称:cavity,代码行数:48,代码来源:JsonFileAttribute.cs

示例7: WriteAllText

        public void WriteAllText()
        {
            // Type
            var @this = new FileInfo(Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "Examples_System_IO_FileInfo_WriteAllText.txt"));

            // Intialization
            using (FileStream stream = @this.Create())
            {
            }

            // Examples
            @this.WriteAllText("Fizz" + Environment.NewLine + "Buzz");

            // Unit Test
            Assert.AreEqual("Fizz" + Environment.NewLine + "Buzz", @this.ReadToEnd());
        }
开发者ID:fqybzhangji,项目名称:Z.ExtensionMethods,代码行数:16,代码来源:FileInfo.WriteAllText.cs

示例8: ReadToEnd

        public void ReadToEnd()
        {
            // Type
            var @this = new FileInfo(Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "Examples_System_IO_FileInfo_ReadToEnd.txt"));

            // Intialization
            using (FileStream stream = @this.Create())
            {
                byte[] byteToWrites = Encoding.Default.GetBytes("Fizz" + Environment.NewLine + "Buzz");
                stream.Write(byteToWrites, 0, byteToWrites.Length);
            }

            // Examples
            string result = @this.ReadToEnd(); // return "Fizz" + Environment.NewLine + "Buzz";

            // Unit Test
            Assert.AreEqual("Fizz" + Environment.NewLine + "Buzz", result);
        }
开发者ID:ChuangYang,项目名称:Z.ExtensionMethods,代码行数:18,代码来源:FileInfo.ReadToEnd.cs

示例9: CreateProcessor

        /// <summary>
        /// Creates the processor that belongs to this data.
        /// </summary>
        /// <returns></returns>
        public override ProcessorBase CreateProcessor()
        {
            // parse geojson file.
            using(var geoJSONFile = new FileInfo(this.GeoJSONFile).OpenText())
            {
                string geoJson = geoJSONFile.ReadToEnd();
                var geoJsonReader = new GeoJsonReader();

                var featureCollection = geoJsonReader.Read<FeatureCollection>(geoJson) as FeatureCollection;

                foreach (var feature in featureCollection.Features)
                {
                    return new ProcessorFeedFilter()
                    { // create a bounding box filter.
                        Filter = new GTFS.Filters.GTFSFeedStopsFilter((s) =>
                        {
                            return feature.Geometry.Covers(new Point(new Coordinate(s.Longitude, s.Latitude)));
                        })
                    };
                }
            }
            throw new Exception("No geometries found in GeoJSON");
        }
开发者ID:Smartrak,项目名称:GTFS,代码行数:27,代码来源:SwitchFilterBoundingGeoJSON.cs

示例10: OpenFile

        void OpenFile(string name)
        {
            _name = name;
            // Open and read the file
            try {
                TextReader reader = new FileInfo(name).OpenText();
                var text = reader.ReadToEnd();
                reader.Dispose();
                var lines = text.Split(new[] {"\r\n"}, StringSplitOptions.RemoveEmptyEntries);

                // Create a new model and solver, and add event listeners
                if (_model != null) {
                    _model.ModelChanged -= HandleModelModelChanged;
                    _solver.ScanFinished -= HandleSolverScanFinished;
                    _solver.Finished -= HandleSolverFinished;
                }
                _model = new SudokuModel(lines.Length);
                _solver = new Solver(_model);
                _model.ModelChanged += HandleModelModelChanged;
                _solver.ScanFinished += HandleSolverScanFinished;
                _solver.Finished += HandleSolverFinished;

                // Update the screen
                _grid.Model = _model;
                _txtProgress.Clear();

                // Load data into the model
                for (var row = 0; row < lines.Length; ++row) {
                    var cells = lines[row].Split(',');
                    for (var col = 0; col < lines.Length; ++col) {
                        if (!string.IsNullOrEmpty(cells[col])) {
                            _model.SetValue(col, row, cells[col][0] - 'A');
                        }
                    }
                }
            } catch (FileNotFoundException) {}
        }
开发者ID:daxfohl,项目名称:SudokuCS,代码行数:37,代码来源:Form1.cs

示例11: GetData

        public override IEnumerable<object[]> GetData(MethodInfo methodUnderTest,
                                                      Type[] parameterTypes)
        {
            if (null == methodUnderTest)
            {
                throw new ArgumentNullException("methodUnderTest");
            }

            if (null == parameterTypes)
            {
                throw new ArgumentNullException("parameterTypes");
            }

            if (0 == parameterTypes.Length)
            {
                throw new InvalidOperationException("A parameter is required.");
            }

            if (1 != parameterTypes.Length)
            {
                throw new InvalidOperationException("Only one parameter is permitted.");
            }

            var list = new List<object>();
            var info = new FileInfo(File);

            if (parameterTypes[0] == typeof(HttpRequest))
            {
                list.Add(HttpRequest.FromString(info.ReadToEnd()));
            }
            else
            {
                throw new InvalidOperationException("Only Http Request is supported as a parameter type.");
            }

            yield return list.ToArray();
        }
开发者ID:KarlDirck,项目名称:cavity,代码行数:37,代码来源:HttpRequestAttribute.cs

示例12: Loadtion

 private void Loadtion(KeyValuePair<String, Script> script)
 {
     var f = new FileInfo(script.Value.sourceFile);
     using (TextReader tr = f.OpenText())
     {
         _sauce = tr.ReadToEnd();
         _name = script.Key;
     }
     if (!String.IsNullOrEmpty(script.Value.refFile))
     {
         using (TextReader trr = new FileInfo(script.Value.refFile).OpenText())
         {
             _refs = trr.ReadToEnd();
         }
     }
 }
开发者ID:L3tum,项目名称:BesiegeScriptingMod,代码行数:16,代码来源:ScriptHandler.cs

示例13: Read

 public void Read(string projectPath)
 {
     try
     {
         LoadedProjectPath = projectPath;
         using(StreamReader reader=new FileInfo(projectPath).OpenText())
             FileContent = reader.ReadToEnd();
     }
     catch (Exception e)
     {
         LastError = e.Message;
     }
 }
开发者ID:jmuria,项目名称:HellBlaster,代码行数:13,代码来源:VS10ProjectReader.cs

示例14: createDatabase

        /* Metodo para crear las tablas en la base de datos seleccionada*/
        private bool createDatabase()
        {
            NpgsqlConnection connection;
            NpgsqlCommand command;

            try
            {
                connection = new NpgsqlConnection(connectionString.ToString());

                StreamReader fsSQL = new FileInfo(myNode.Addin.GetFilePath("subscription.sql")).OpenText();
                string SQL_Script = fsSQL.ReadToEnd();
                fsSQL.Close();
                command = new NpgsqlCommand(SQL_Script, connection);

                connection.Open();

                if(command.ExecuteNonQuery() == 0)
                {
                    connection.Close();
                    MessageDialog md = new MessageDialog(null, DialogFlags.Modal, MessageType.Error, ButtonsType.Close, "Error connection");
               		md.Run();
               		md.Destroy();
                    connection.Close();
                    return false;
                }
            }
            catch(NpgsqlException ex)
            {
                MessageDialog md = new MessageDialog(null, DialogFlags.Modal, MessageType.Error, ButtonsType.Close, "Error connection: " + ex.Message);
               	md.Run();
               	md.Destroy();
                connection.Close();
            }

            return true;
        }
开发者ID:denisjev,项目名称:SubscriptionService,代码行数:37,代码来源:ConnectionHandler.cs

示例15: GetData

        public override IEnumerable<object[]> GetData(MethodInfo methodUnderTest,
                                                      Type[] parameterTypes)
        {
            if (null == methodUnderTest)
            {
                throw new ArgumentNullException("methodUnderTest");
            }

            if (null == parameterTypes)
            {
                throw new ArgumentNullException("parameterTypes");
            }

#if NET20
            if (Cavity.Collections.IEnumerableExtensionMethods.Count(Files) != parameterTypes.Length)
            {
                throw new InvalidOperationException(StringExtensionMethods.FormatWith(Resources.Attribute_CountsDiffer, Cavity.Collections.IEnumerableExtensionMethods.Count(Files), parameterTypes.Length));
            }
#else
            if (Files.Count() != parameterTypes.Length)
            {
                throw new InvalidOperationException(Resources.Attribute_CountsDiffer.FormatWith(Files.Count(), parameterTypes.Length));
            }
#endif

            var list = new List<object>();
            var index = -1;
            foreach (var file in Files)
            {
                var info = new FileInfo(file);
                index++;

                if (parameterTypes[index] == typeof(DataSet))
                {
                    var data = new DataSet();
                    data.ReadXml(info.FullName, XmlReadMode.Auto);

                    list.Add(data);
                    continue;
                }

                if (parameterTypes[index] == typeof(XmlDocument) || parameterTypes[index] == typeof(IXPathNavigable))
                {
                    var xml = new XmlDocument();
                    xml.Load(info.FullName);

                    list.Add(xml);
                    continue;
                }

                if (parameterTypes[index] == typeof(XPathNavigator))
                {
                    var xml = new XmlDocument();
                    xml.Load(info.FullName);

                    list.Add(xml.CreateNavigator());
                    continue;
                }

#if !NET20
                if (parameterTypes[index] == typeof(XDocument))
                {
                    list.Add(XDocument.Load(info.FullName));
                    continue;
                }
#endif

#if NET20
                list.Add(StringExtensionMethods.XmlDeserialize(FileInfoExtensionMethods.ReadToEnd(info), parameterTypes[index]));
#else
                list.Add(info.ReadToEnd().XmlDeserialize(parameterTypes[index]));
#endif
            }

            yield return list.ToArray();
        }
开发者ID:KarlDirck,项目名称:cavity,代码行数:76,代码来源:XmlFileAttribute.cs


注:本文中的System.IO.FileInfo.ReadToEnd方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。