Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions docs/standard/io/asynchronous-file-i-o.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ helpviewer_keywords:
- "asynchronous I/O"
- "synchronous I/O"
- "streams, asynchronous streams"
- "I/O [.NET Framework], asynchronous I/O"
- "I/O [.NET], asynchronous I/O"
- "Stream class, synchronous I/O"
- "data streams, asynchronous streams"
- "Stream class, asynchronous I/O"
Expand All @@ -23,9 +23,9 @@ ms.assetid: dbdd55e7-d6b9-4f9e-8abb-ab0edd4457f7

Asynchronous operations enable you to perform resource-intensive I/O operations without blocking the main thread. This performance consideration is particularly important in a Windows 8.x Store app or desktop app where a time-consuming stream operation can block the UI thread and make your app appear as if it is not working.

Starting with the .NET Framework 4.5, the I/O types include async methods to simplify asynchronous operations. An async method contains `Async` in its name, such as <xref:System.IO.Stream.ReadAsync%2A>, <xref:System.IO.Stream.WriteAsync%2A>, <xref:System.IO.Stream.CopyToAsync%2A>, <xref:System.IO.Stream.FlushAsync%2A>, <xref:System.IO.TextReader.ReadLineAsync%2A>, and <xref:System.IO.TextReader.ReadToEndAsync%2A>. These async methods are implemented on stream classes, such as <xref:System.IO.Stream>, <xref:System.IO.FileStream>, and <xref:System.IO.MemoryStream>, and on classes that are used for reading from or writing to streams, such <xref:System.IO.TextReader> and <xref:System.IO.TextWriter>.
Starting with .NET Framework 4.5, the I/O types include async methods to simplify asynchronous operations. An async method contains `Async` in its name, such as <xref:System.IO.Stream.ReadAsync%2A>, <xref:System.IO.Stream.WriteAsync%2A>, <xref:System.IO.Stream.CopyToAsync%2A>, <xref:System.IO.Stream.FlushAsync%2A>, <xref:System.IO.TextReader.ReadLineAsync%2A>, and <xref:System.IO.TextReader.ReadToEndAsync%2A>. These async methods are implemented on stream classes, such as <xref:System.IO.Stream>, <xref:System.IO.FileStream>, and <xref:System.IO.MemoryStream>, and on classes that are used for reading from or writing to streams, such <xref:System.IO.TextReader> and <xref:System.IO.TextWriter>.

In the .NET Framework 4 and earlier versions, you have to use methods such as <xref:System.IO.Stream.BeginRead%2A> and <xref:System.IO.Stream.EndRead%2A> to implement asynchronous I/O operations. These methods are still available in the .NET Framework 4.5 to support legacy code; however, the async methods help you implement asynchronous I/O operations more easily.
In .NET Framework 4 and earlier versions, you have to use methods such as <xref:System.IO.Stream.BeginRead%2A> and <xref:System.IO.Stream.EndRead%2A> to implement asynchronous I/O operations. These methods are still available in current .NET versions to support legacy code; however, the async methods help you implement asynchronous I/O operations more easily.

C# and Visual Basic each have two keywords for asynchronous programming:

Expand Down
2 changes: 1 addition & 1 deletion docs/standard/io/composing-streams.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ dev_langs:
- "cpp"
helpviewer_keywords:
- "streams, base streams"
- "I/O [.NET Framework], composing streams"
- "I/O [.NET], composing streams"
- "Stream class, composing streams"
- "base streams"
- "streams, backing stores"
Expand Down
6 changes: 3 additions & 3 deletions docs/standard/io/file-path-formats.md
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ The DOS device path consists of the following components:
- The device path specifier (`\\.\` or `\\?\`), which identifies the path as a DOS device path.

> [!NOTE]
> The `\\?\` is supported in all versions of .NET Core and in the .NET Framework starting with version 4.6.2.
> The `\\?\` is supported in all versions of .NET Core and .NET 5+ and in .NET Framework starting with version 4.6.2.

- A symbolic link to the "real" device object (C: in the case of a drive name, or Volume{b75e2c83-0000-0000-0000-602f00000000} in the case of a volume GUID).

Expand Down Expand Up @@ -188,10 +188,10 @@ Why would you want to skip normalization? There are three major reasons:

1. To improve performance by skipping normalization if you've already normalized.

1. On the .NET Framework only, to skip the `MAX_PATH` check for path length to allow for paths that are greater than 259 characters. Most APIs allow this, with some exceptions.
1. On .NET Framework only, to skip the `MAX_PATH` check for path length to allow for paths that are greater than 259 characters. Most APIs allow this, with some exceptions.

> [!NOTE]
> .NET Core handles long paths implicitly and does not perform a `MAX_PATH` check. The `MAX_PATH` check applies only to the .NET Framework.
> .NET Core and .NET 5+ handles long paths implicitly and does not perform a `MAX_PATH` check. The `MAX_PATH` check applies only to .NET Framework.

Skipping normalization and max path checks is the only difference between the two device path syntaxes; they are otherwise identical. Be careful with skipping normalization, since you can easily create paths that are difficult for "normal" applications to deal with.

Expand Down
2 changes: 1 addition & 1 deletion docs/standard/io/handling-io-errors.md
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ However, the precise conditions under which the operating system returns particu

Because of this reliance on the operating system, identical exception conditions (such as the directory not found error in our example) can result in an I/O method throwing any one of the entire class of I/O exceptions. This means that, when calling I/O APIs, your code should be prepared to handle most or all of these exceptions, as shown in the following table:

| Exception type | .NET Core | .NET Framework |
| Exception type | .NET Core/.NET 5+ | .NET Framework |
|---|---|---|
| <xref:System.IO.IOException> | Yes | Yes |
| <xref:System.IO.FileNotFoundException> | Yes | Yes |
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ helpviewer_keywords:
ms.assetid: 53758b39-bd9b-4640-bb04-cad5ed8d0abf
---
# How to: Add or remove Access Control List entries (.NET Framework only)

To add or remove Access Control List (ACL) entries to or from a file or directory, get the <xref:System.Security.AccessControl.FileSecurity> or <xref:System.Security.AccessControl.DirectorySecurity> object from the file or directory. Modify the object, and then apply it back to the file or directory.

## Add or remove an ACL entry from a file
Expand Down
2 changes: 1 addition & 1 deletion docs/standard/io/how-to-compress-and-extract-files.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ dev_langs:
- "csharp"
- "vb"
helpviewer_keywords:
- "I/O [.NET Framework], compression"
- "I/O [.NET], compression"
- "compression"
- "compress files"
ms.assetid: e9876165-3c60-4c84-a272-513e47acf579
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ ms.assetid: 23a763ea-8348-4244-9f8c-a4280b870b47
---
# How to: Convert between .NET Framework and Windows Runtime streams (Windows only)

The .NET Framework for UWP apps is a subset of the full .NET Framework. Because of security and other requirements for UWP apps, you can't use the full set of .NET Framework APIs to open and read files. For more information, see [.NET for UWP apps overview](/previous-versions/windows/apps/br230302(v=vs.140)). However, you may want to use .NET Framework APIs for other stream manipulation operations. To manipulate these streams, you can convert between a .NET Framework stream type such as <xref:System.IO.MemoryStream> or <xref:System.IO.FileStream>, and a Windows Runtime stream such as <xref:Windows.Storage.Streams.IInputStream>, <xref:Windows.Storage.Streams.IOutputStream>, or <xref:Windows.Storage.Streams.IRandomAccessStream>.
.NET Framework for UWP apps is a subset of the full .NET Framework. Because of security and other requirements for UWP apps, you can't use the full set of .NET Framework APIs to open and read files. For more information, see [.NET for UWP apps overview](/previous-versions/windows/apps/br230302(v=vs.140)). However, you may want to use .NET Framework APIs for other stream manipulation operations. To manipulate these streams, you can convert between a .NET Framework stream type, such as <xref:System.IO.MemoryStream> or <xref:System.IO.FileStream>, and a Windows Runtime stream, such as <xref:Windows.Storage.Streams.IInputStream>, <xref:Windows.Storage.Streams.IOutputStream>, or <xref:Windows.Storage.Streams.IRandomAccessStream>.

The <xref:System.IO.WindowsRuntimeStreamExtensions?displayProperty=nameWithType> class contains methods that make these conversions easy. However, underlying differences between .NET Framework and Windows Runtime streams affect the results of using these methods, as described in the following sections:

Expand All @@ -24,7 +24,7 @@ To convert from a Windows Runtime stream to a .NET Framework stream, use one of

The Windows Runtime offers stream types that support reading only, writing only, or reading and writing. These capabilities are maintained when you convert a Windows Runtime stream to a .NET Framework stream. Furthermore, if you convert a Windows Runtime stream to a .NET Framework stream and back, you get the original Windows Runtime instance back.

Its best practice to use the conversion method that matches the capabilities of the Windows Runtime stream you want to convert. However, since <xref:Windows.Storage.Streams.IRandomAccessStream> is readable and writeable (it implements both <xref:Windows.Storage.Streams.IOutputStream> and <xref:Windows.Storage.Streams.IInputStream>), the conversion methods maintain the capabilities of the original stream. For example, using <xref:System.IO.WindowsRuntimeStreamExtensions.AsStreamForRead%2A?displayProperty=nameWithType> to convert an <xref:Windows.Storage.Streams.IRandomAccessStream> doesn't limit the converted .NET Framework stream to being readable. It's also writable.
It's best practice to use the conversion method that matches the capabilities of the Windows Runtime stream you want to convert. However, since <xref:Windows.Storage.Streams.IRandomAccessStream> is readable and writeable (it implements both <xref:Windows.Storage.Streams.IOutputStream> and <xref:Windows.Storage.Streams.IInputStream>), the conversion methods maintain the capabilities of the original stream. For example, using <xref:System.IO.WindowsRuntimeStreamExtensions.AsStreamForRead%2A?displayProperty=nameWithType> to convert an <xref:Windows.Storage.Streams.IRandomAccessStream> doesn't limit the converted .NET Framework stream to being readable. It's also writable.

## Example: Convert Windows Runtime random-access to .NET Framework stream
To convert from a Windows Runtime random-access stream to a .NET Framework stream, use the <xref:System.IO.WindowsRuntimeStreamExtensions.AsStream%2A?displayProperty=nameWithType> method.
Expand Down
7 changes: 4 additions & 3 deletions docs/standard/io/how-to-copy-directories.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,14 +8,15 @@ dev_langs:
- "vb"
helpviewer_keywords:
- "directory copying"
- "I/O [.NET Framework], copying directories"
- "I/O [.NET], copying directories"
- "subdirectory copying"
- "copying directories"
- "directories [.NET Framework], copying"
- "directories [.NET], copying"
ms.assetid: 5a969765-e5f8-4b4e-977e-90e2b0a1fe3c
---
# How to: Copy directories
This topic demonstrates how to use I/O classes to synchronously copy the contents of a directory to another location.

This article demonstrates how to use I/O classes to synchronously copy the contents of a directory to another location.

For an example of asynchronous file copy, see [Asynchronous file I/O](asynchronous-file-i-o.md).

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@ dev_langs:
- "csharp"
- "vb"
helpviewer_keywords:
- "directories [.NET Framework], isolated storage"
- "files [.NET Framework], isolated storage"
- "directories [.NET], isolated storage"
- "files [.NET], isolated storage"
- "isolated storage, creating files and directories"
- "data stores, creating files and directories"
- "data storage using isolated storage, creating files and directories"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@ dev_langs:
- "cpp"
helpviewer_keywords:
- "data storage using isolated storage, deleting files and directories"
- "directories [.NET Framework], isolated storage"
- "files [.NET Framework], isolated storage"
- "directories [.NET], isolated storage"
- "files [.NET], isolated storage"
- "isolated storage, deleting files and directories"
- "data stores, deleting files and directories"
- "stores, creating files and directories"
Expand Down
2 changes: 1 addition & 1 deletion docs/standard/io/how-to-enumerate-directories-and-files.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ dev_langs:
- "csharp"
- "vb"
helpviewer_keywords:
- "I/O [.NET Framework], enumerating directories and files"
- "I/O [.NET], enumerating directories and files"
ms.assetid: 86b69a08-3bfa-4e5f-b4e1-3b7cb8478215
---
# How to: Enumerate directories and files
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,10 @@ dev_langs:
helpviewer_keywords:
- "stores, finding files and directories"
- "locating files in isolated storage file"
- "directories [.NET Framework], isolated storage"
- "directories [.NET], isolated storage"
- "isolated storage, finding files and directories"
- "data storage using isolated storage, finding files and directories"
- "files [.NET Framework], isolated storage"
- "files [.NET], isolated storage"
- "data stores, finding files and directories"
- "locating directories in isolated storage file"
- "storing data using isolated storage, finding files and directories"
Expand Down
3 changes: 2 additions & 1 deletion docs/standard/io/how-to-open-and-append-to-a-log-file.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,11 @@ helpviewer_keywords:
- "log files, opening"
- "streams, opening and appending to log file"
- "log files, appending to"
- "I/O [.NET Framework], log files"
- "I/O [.NET], log files"
ms.assetid: 74423362-1721-49cb-aa0a-e04005f72a06
---
# How to: Open and append to a log file

<xref:System.IO.StreamWriter> and <xref:System.IO.StreamReader> write characters to and read characters from streams. The following code example opens the *log.txt* file for input, or creates it if it doesn't exist, and appends log information to the end of the file. The example then writes the contents of the file to standard output for display.

As an alternative to this example, you could store the information as a single string or string array, and use the <xref:System.IO.File.WriteAllText%2A?displayProperty=nameWithType> or <xref:System.IO.File.WriteAllLines%2A?displayProperty=nameWithType> method to achieve the same functionality.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,13 @@ dev_langs:
helpviewer_keywords:
- "streams, reading and writing data"
- "BinaryReader class, examples"
- "I/O [.NET Framework], reading data"
- "I/O [.NET Framework], writing data"
- "I/O [.NET], reading data"
- "I/O [.NET], writing data"
- "BinaryWriter class, examples"
ms.assetid: e209d949-31e8-44ea-8e38-87f9093f3093
---
# How to: Read and write to a newly created data file

The <xref:System.IO.BinaryWriter?displayProperty=nameWithType> and <xref:System.IO.BinaryReader?displayProperty=nameWithType> classes are used for writing and reading data other than character strings. The following example shows how to create an empty file stream, write data to it, and read data from it.

The example creates a data file called *Test.data* in the current directory, creates the associated <xref:System.IO.BinaryWriter> and <xref:System.IO.BinaryReader> objects, and uses the <xref:System.IO.BinaryWriter> object to write the integers 0 through 10 to *Test.data*, which leaves the file pointer at the end of the file. The <xref:System.IO.BinaryReader> object then sets the file pointer back to the origin and reads out the specified content.
Expand Down
3 changes: 2 additions & 1 deletion docs/standard/io/how-to-read-characters-from-a-string.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,13 @@ dev_langs:
helpviewer_keywords:
- "reading characters from strings"
- "data streams, reading characters from string"
- "I/O [.NET Framework], reading characters from strings"
- "I/O [.NET], reading characters from strings"
- "reading data, strings"
- "streams, reading characters from string"
ms.assetid: 27ea5e52-6db8-42d8-980a-50bcfc7fd270
---
# How to: Read characters from a string

The following code examples show how to read characters synchronously or asynchronously from a string.

## Example: Read characters synchronously
Expand Down
5 changes: 3 additions & 2 deletions docs/standard/io/how-to-read-text-from-a-file.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,14 +11,15 @@ helpviewer_keywords:
- "reading text files"
- "reading data, text files"
- "data streams, reading text from files"
- "I/O [.NET Framework], reading text from files"
- "I/O [.NET], reading text from files"
ms.assetid: ed180baa-dfc6-4c69-a725-46e87edafb27
---
# How to: Read text from a file

The following examples show how to read text synchronously and asynchronously from a text file using .NET for desktop apps. In both examples, when you create the instance of the <xref:System.IO.StreamReader> class, you provide the relative or absolute path to the file.

> [!NOTE]
> These code examples do not apply to developing for Universal Windows (UWP) apps, because the Windows Runtime provides different stream types for reading and writing to files. For an example that shows how to read text from a file in a UWP app, see [Quickstart: Reading and writing files](/previous-versions/windows/apps/hh758325(v=win.10)). For examples that show how to convert between .NET Framework streams and Windows Runtime streams, see [How to: Convert between .NET Framework streams and Windows Runtime streams](how-to-convert-between-dotnet-streams-and-winrt-streams.md).
> These code examples do not apply to Universal Windows (UWP) apps, because the Windows Runtime provides different stream types for reading and writing to files. For an example that shows how to read text from a file in a UWP app, see [Quickstart: Reading and writing files](/previous-versions/windows/apps/hh758325(v=win.10)). For examples that show how to convert between .NET Framework streams and Windows Runtime streams, see [How to: Convert between .NET Framework streams and Windows Runtime streams](how-to-convert-between-dotnet-streams-and-winrt-streams.md).

## Example: Synchronous read in a console app
The following example shows a synchronous read operation within a console app. This example opens the text file using a stream reader, copies the contents to a string, and outputs the string to the console.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,14 +8,15 @@ dev_langs:
- "vb"
- "cpp"
helpviewer_keywords:
- "anonymous pipes [.NET Framework]"
- "parent-child communication [.NET Framework]"
- "pipes [.NET Framework]"
- "one-way communication [.NET Framework]"
- "local computer communication [.NET Framework], pipes"
- "anonymous pipes [.NET]"
- "parent-child communication [.NET]"
- "pipes [.NET]"
- "one-way communication [.NET]"
- "local computer communication [.NET], pipes"
ms.assetid: e7773c77-c646-4a01-8a96-a003d59fc4c9
---
# How to: Use Anonymous Pipes for Local Interprocess Communication

Anonymous pipes provide interprocess communication on a local computer. They offer less functionality than named pipes, but also require less overhead. You can use anonymous pipes to make interprocess communication on a local computer easier. You cannot use anonymous pipes for communication over a network.

To implement anonymous pipes, use the <xref:System.IO.Pipes.AnonymousPipeServerStream> and <xref:System.IO.Pipes.AnonymousPipeClientStream> classes.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,16 +8,17 @@ dev_langs:
- "vb"
- "cpp"
helpviewer_keywords:
- "message-based communication [.NET Framework], named pipes"
- "named pipes [.NET Framework]"
- "pipes [.NET Framework]"
- "message-based communication [.NET], named pipes"
- "named pipes [.NET]"
- "pipes [.NET]"
- "multiple connections via named pipes"
- "network communications [.NET Framework], named pipes"
- "impersonation [.NET Framework], named pipes"
- "full duplex communication [.NET Framework], named pipes"
- "network communications [.NET], named pipes"
- "impersonation [.NET], named pipes"
- "full duplex communication [.NET], named pipes"
ms.assetid: 4e4d7e64-9f1b-4026-98f7-20488ac7b42b
---
# How to: Use Named Pipes for Network Interprocess Communication

Named pipes provide interprocess communication between a pipe server and one or more pipe clients. They offer more functionality than anonymous pipes, which provide interprocess communication on a local computer. Named pipes support full duplex communication over a network and multiple server instances, message-based communication, and client impersonation, which enables connecting processes to use their own set of permissions on remote servers.

To implement name pipes, use the <xref:System.IO.Pipes.NamedPipeServerStream> and <xref:System.IO.Pipes.NamedPipeClientStream> classes.
Expand Down
Loading