O'Reilly logo

Professional C# 6 and .NET Core 1.0 by Christian Nagel

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

23 Files and Streams

What’s In This Chapter?

  • Exploring the directory structure
  • Moving, copying, and deleting files and folders
  • Reading and writing text in files
  • Using streams to read and write files
  • Using readers and writers to read and write files
  • Compressing files
  • Monitor file changes
  • Communication using pipes
  • Using Windows Runtime streams

Wrox.com Code Downloads for This Chapter

The wrox.com code downloads for this chapter are found at www.wrox.com/go/professionalcsharp6 on the Download Code tab. The code for this chapter is divided into the following major examples:

  • DriveInformation
  • WorkingWithFilesAndFolders
  • WPFEditor
  • StreamSamples
  • ReaderWriterSamples
  • CompressFileSample
  • FileMonitor
  • MemoryMappedFiles
  • NamedPipes
  • AnonymousPipes
  • WindowsAppEditor

Introduction

When you’re reading and writing to files and directories you can use simple APIs, or you can use advanced ones that offer more features. You also have to differentiate between .NET classes and functionality offered from the Windows Runtime. From Universal Windows Platform (UWP) Windows apps, you don’t have access to the file system in any directory; you have access only to specific directories. Alternatively, you can let the user pick files. This chapter covers all these options. You’ll read and write files by using a simple API and get into more features by using streams. You’ll use both .NET types and types from the Windows Runtime, and you’ll mix both of these technologies to take advantage of .NET features with ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required