About 46,000 results
Open links in new tab
  1. c# - Easiest way to read from and write to files - Stack Overflow

    Sep 27, 2011 · There are a lot of different ways to read and write files (text files, not binary) in C#. I just need something that is easy and uses the least amount of code, because I am going to be working with

  2. c# - How to log to a file without using third party logger in .Net Core ...

    How to log to a file without using third party logger (serilog, elmah etc.) in .NET CORE? public void ConfigureServices(IServiceCollection services) { services.AddLogging(); } public void Con...

  3. What is the difference between File and FileInfo in C#?

    File is optimized for one-off operations on a file, FileInfo is optimized around multiple operations on the same file, but in general there isn't that much difference between the different method implementations.

  4. c# - How to rewrite a file or append to a file using StreamWriter ...

    StreamWriter's default behavior is to create a new file, or overwrite it if it exists. To append to the file you'll need to use the overload that accepts a boolean and set that to true. In your example code, …

  5. c# - How to get File Created Date and Modified Date - Stack Overflow

    Apr 23, 2014 · I have an .NET EXE file . I want to find the file created date and modified date in C# application. Can do it through reflection or with IO stream?

  6. How to find out if a file exists in C# / .NET? - Stack Overflow

    Sep 2, 2008 · I would like to test a string containing a path to a file for existence of that file (something like the -e test in Perl or the os.path.exists() in Python) in C#.

  7. c# - Open existing file, append a single line - Stack Overflow

    May 14, 2010 · I want to open a text file, append a single line to it, then close it.

  8. .net - Creating an empty file in C# - Stack Overflow

    Nov 23, 2016 · What's the simplest/canonical way to create an empty file in C#/.NET? The simplest way I could find so far is: System.IO.File.WriteAllLines(filename, new string[0]);

  9. Writing data into CSV file in C# - Stack Overflow

    Sep 12, 2013 · File.AppendAllText() opens a new file, writes the content and then closes the file. Opening files is a much resource-heavy operation, than writing data into open stream.

  10. How to read an entire file to a string using C#? - Stack Overflow

    What is the quickest way to read a text file into a string variable? I understand it can be done in several ways, such as read individual bytes and then convert those to string. I was looking for a