Skip to content

Commit fe04793

Browse files
v-kentsmairaw
authored andcommitted
add content from MSDN pages (#1970)
* add content from MSDN pages * edit to kick build * add missing format tag * Apply suggestions from code review Co-Authored-By: v-kents <[email protected]> * edits from code review * add remarks header * Apply suggestions from code review Co-Authored-By: v-kents <[email protected]> * markdown formatting cleanup * add correct xref to overloaded methods * convert to LF line endings, update /dotnet/ to ~docs/ * change ~/docs to ~/api * change reference from ~/api/ to ~/ * switch links back to ~/docs * fixes * fixes * fixes * fixes * add missing methods back
1 parent b70a515 commit fe04793

File tree

2 files changed

+365
-64
lines changed

2 files changed

+365
-64
lines changed

xml/System.IO/WindowsRuntimeStorageExtensions.xml

Lines changed: 137 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,36 @@
2020
</Attribute>
2121
</Attributes>
2222
<Docs>
23-
<summary>To be added.</summary>
24-
<remarks>To be added.</remarks>
23+
<summary>Contains extension methods for the <see cref="T:Windows.Storage.IStorageFile"/> and <see cref="T:Windows.Storage.IStorageFolder"/> interfaces in the Windows Runtime when developing Windows Store apps.</summary>
24+
<remarks>
25+
<format type="text/markdown"><![CDATA[
26+
27+
## Remarks
28+
29+
These extension methods are available only when you develop Windows Store apps. The methods provide convenient ways of opening files for reading or writing in Windows Store apps. You do not create an instance of the `WindowsRuntimeStorageExtensions` class; instead, you use these methods from instances of the <xref:Windows.Storage.IStorageFile> and <xref:Windows.Storage.IStorageFolder> interfaces.
30+
31+
The `WindowsRuntimeStorageExtensions` class contains two methods that extend <xref:Windows.Storage.IStorageFile> for reading or writing:
32+
33+
- <xref:System.IO.WindowsRuntimeStorageExtensions.OpenStreamForReadAsync(Windows.Storage.IStorageFile)>
34+
- <xref:System.IO.WindowsRuntimeStorageExtensions.OpenStreamForWriteAsync(Windows.Storage.IStorageFile)>
35+
36+
The WindowsRuntimeStorageExtensions class contains two methods that extend <xref:Windows.Storage.IStorageFolder> for reading and writing:
37+
- <xref:System.IO.WindowsRuntimeStorageExtensions.OpenStreamForReadAsync(Windows.Storage.IStorageFolder,System.String)>
38+
- <xref:System.IO.WindowsRuntimeStorageExtensions.OpenStreamForWriteAsync(Windows.Storage.IStorageFolder,System.String,Windows.Storage.CreationCollisionOption)>
39+
40+
## Examples
41+
42+
The following example shows how to open a file in the application data as a <xref:System.IO.Stream> in a Windows Store app, and write to it by using an instance of the <xref:System.IO.StreamWriter> class. It then reads the contents for the file by using an instance of the <xref:System.IO.StreamReader> class.
43+
44+
[!code-csharp[windowsruntimestorageextensions#8](~/samples/snippets/csharp/VS_Snippets_CLR_System/system.io.windowsruntimestorageextensions/cs/blankpage4.xaml.cs#8)]
45+
[!code-vb[windowsruntimestorageextensions#8](~/samples/snippets/visualbasic/VS_Snippets_CLR_System/system.io.windowsruntimestorageextensions/vb/blankpage4.xaml.vb#8)]
46+
47+
The next example shows the XAML code that is associated with the previous example.
48+
49+
[!code-xaml[windowsruntimestorageextensions#7](~/samples/snippets/csharp/VS_Snippets_CLR_System/system.io.windowsruntimestorageextensions/cs/blankpage4.xaml#7)]
50+
51+
]]></format>
52+
</remarks>
2553
</Docs>
2654
<Members>
2755
<Member MemberName="CreateSafeFileHandle">
@@ -157,10 +185,31 @@
157185
<Parameter Name="windowsRuntimeFile" Type="Windows.Storage.IStorageFile" RefType="this" />
158186
</Parameters>
159187
<Docs>
160-
<param name="windowsRuntimeFile">To be added.</param>
161-
<summary>To be added.</summary>
162-
<returns>To be added.</returns>
163-
<remarks>To be added.</remarks>
188+
<param name="windowsRuntimeFile">The Windows Runtime <see cref="T:Windows.Storage.IStorageFile"/> object to read from.</param>
189+
<summary>Retrieves a stream for reading from a specified file.</summary>
190+
<returns>A task that represents the asynchronous read operation.</returns>
191+
<remarks>
192+
<format type="text/markdown"><![CDATA[
193+
## Remarks
194+
195+
> [!NOTE]
196+
> In Visual Basic and C#, you can call this method as an instance method on any object of type <xref:Windows.Storage.IStorageFile>. When you use instance method syntax to call this method, omit the first parameter. For more information, see [Extension Methods (Visual Basic)](~/docs/visual-basic/programming-guide/language-features/procedures/extension-methods.md) or [Extension Methods (C# Programming Guide)](~/docs/csharp/programming-guide/classes-and-structs/extension-methods.md).
197+
198+
## Examples
199+
200+
The following example shows how to open a file as a <xref:System.IO.Stream> in a Windows Store app, and read its contents by using an instance of the <xref:System.IO.StreamReader> class.
201+
202+
[!code-csharp[windowsruntimestorageextensions#2](~/samples/snippets/csharp/VS_Snippets_CLR_System/system.io.windowsruntimestorageextensions/cs/blankpage.xaml.cs#2)]
203+
[!code-vb[windowsruntimestorageextensions#2](~/samples/snippets/visualbasic/VS_Snippets_CLR_System/system.io.windowsruntimestorageextensions/vb/blankpage.xaml.vb#2)]
204+
205+
The next example shows the XAML code that is associated with the previous example.
206+
207+
[!code-xaml[windowsruntimestorageextensions#1](~/samples/snippets/csharp/VS_Snippets_CLR_System/system.io.windowsruntimestorageextensions/cs/blankpage.xaml#1)]
208+
209+
]]></format>
210+
</remarks>
211+
<exception cref="T:System.ArgumentNullException"><paramref name="windowsRuntimeFile" /> is <see langword="null" />.</exception>
212+
<exception cref="T:System.IO.IOException">The file could not be opened or retrieved as a stream.</exception>
164213
</Docs>
165214
</Member>
166215
<Member MemberName="OpenStreamForReadAsync">
@@ -189,11 +238,34 @@
189238
<Parameter Name="relativePath" Type="System.String" />
190239
</Parameters>
191240
<Docs>
192-
<param name="rootDirectory">To be added.</param>
193-
<param name="relativePath">To be added.</param>
194-
<summary>To be added.</summary>
195-
<returns>To be added.</returns>
196-
<remarks>To be added.</remarks>
241+
<param name="rootDirectory">The Windows Runtime <see cref="T:Windows.Storage.IStorageFile" /> object that contains the file to read from.</param>
242+
<param name="relativePath">The path, relative to the root folder, to the file to read from.</param>
243+
<summary>Retrieves a stream for reading from a file in the specified parent folder.</summary>
244+
<returns>A task that represents the asynchronous read operation.</returns>
245+
<remarks>
246+
<format type="text/markdown"><![CDATA[
247+
248+
## Remarks
249+
250+
> [!NOTE]
251+
> In Visual Basic and C#, you can call this method as an instance method on any object of type IStorageFolder. When you use instance method syntax to call this method, omit the first parameter. For more information, see [Extension Methods (Visual Basic)](~/docs/visual-basic/programming-guide/language-features/procedures/extension-methods.md) or [Extension Methods (C# Programming Guide)](~/docs/csharp/programming-guide/classes-and-structs/extension-methods.md).
252+
253+
## Examples
254+
255+
The following example shows how to open a file as a <xref:System.IO.Stream> in a Windows Store app, and read its contents by using an instance of the <xref:System.IO.StreamReader> class.
256+
257+
[!code-csharp[windowsruntimestorageextensions#4](~/samples/snippets/csharp/VS_Snippets_CLR_System/system.io.windowsruntimestorageextensions/cs/blankpage2.xaml.cs#4)]
258+
[!code-vb[windowsruntimestorageextensions#4](~/samples/snippets/visualbasic/VS_Snippets_CLR_System/system.io.windowsruntimestorageextensions/vb/blankpage2.xaml.vb#4)]
259+
260+
The next example shows the XAML code that is associated with the previous example.
261+
262+
[!code-xaml[windowsruntimestorageextensions#3](~/samples/snippets/csharp/VS_Snippets_CLR_System/system.io.windowsruntimestorageextensions/cs/blankpage2.xaml#3)]
263+
264+
]]></format>
265+
</remarks>
266+
<exception cref="T:System.ArgumentNullException"><paramref name="rootDirectory" /> or <paramref name="relativePath" /> is <see langword="null" />.</exception>
267+
<exception cref="T:System.ArgumentException"><paramref name="relativePath" /> is empty or contains only white-space characters.</exception>
268+
<exception cref="T:System.IO.IOException">The file could not be opened or retrieved as a stream.</exception>
197269
</Docs>
198270
</Member>
199271
<Member MemberName="OpenStreamForWriteAsync">
@@ -221,10 +293,31 @@
221293
<Parameter Name="windowsRuntimeFile" Type="Windows.Storage.IStorageFile" RefType="this" />
222294
</Parameters>
223295
<Docs>
224-
<param name="windowsRuntimeFile">To be added.</param>
225-
<summary>To be added.</summary>
226-
<returns>To be added.</returns>
227-
<remarks>To be added.</remarks>
296+
<param name="windowsRuntimeFile">The Windows Runtime <see cref="T:Windows.Storage.IStorageFile"/> object to write to.</param>
297+
<summary>Retrieves a stream for writing to a specified file.</summary>
298+
<returns>A task that represents the asynchronous write operation.</returns>
299+
<remarks>
300+
<format type="text/markdown"><![CDATA[
301+
## Remarks
302+
303+
> [!NOTE]
304+
> In Visual Basic and C#, you can call this method as an instance method on any object of type <xref:Windows.Storage.IStorageFile>. When you use instance method syntax to call this method, omit the first parameter. For more information, see [Extension Methods (Visual Basic)](~/docs/visual-basic/programming-guide/language-features/procedures/extension-methods.md) or [Extension Methods (C# Programming Guide)](~/docs/csharp/programming-guide/classes-and-structs/extension-methods.md).
305+
306+
## Examples
307+
308+
The following example shows how to open a file as a <xref:System.IO.Stream> in a Windows Store app, and write to it by using an instance of the <xref:System.IO.StreamReader> class.
309+
310+
[!code-csharp[windowsruntimestorageextensions#6](~/samples/snippets/csharp/VS_Snippets_CLR_System/system.io.windowsruntimestorageextensions/cs/blankpage3.xaml.cs#6)]
311+
[!code-vb[windowsruntimestorageextensions#6](~/samples/snippets/visualbasic/VS_Snippets_CLR_System/system.io.windowsruntimestorageextensions/vb/blankpage3.xaml.vb#6)]
312+
313+
The next example shows the XAML code that is associated with the previous example.
314+
315+
[!code-xaml[windowsruntimestorageextensions#5](~/samples/snippets/csharp/VS_Snippets_CLR_System/system.io.windowsruntimestorageextensions/cs/blankpage3.xaml#5)]
316+
317+
]]></format>
318+
</remarks>
319+
<exception cref="T:System.ArgumentNullException"><paramref name="windowsRuntimeFile" /> is <see langword="null" />.</exception>
320+
<exception cref="T:System.IO.IOException">The file could not be opened or retrieved as a stream.</exception>
228321
</Docs>
229322
</Member>
230323
<Member MemberName="OpenStreamForWriteAsync">
@@ -253,13 +346,35 @@
253346
<Parameter Name="creationCollisionOption" Type="Windows.Storage.CreationCollisionOption" />
254347
</Parameters>
255348
<Docs>
256-
<param name="rootDirectory">To be added.</param>
257-
<param name="relativePath">To be added.</param>
258-
<param name="creationCollisionOption">To be added.</param>
259-
<summary>To be added.</summary>
260-
<returns>To be added.</returns>
261-
<remarks>To be added.</remarks>
349+
<param name="rootDirectory">The Windows Runtime <see cref="T:Windows.Storage.IStorageFile"/> object that contains the file to write to.</param>
350+
<param name="relativePath">The path, relative to the root folder, to the file to write to.</param>
351+
<param name="creationCollisionOption">The Windows Runtime <see cref="T:Windows.Storage.CreationCollisionOption" /> enumeration value that specifies the behavior to use when the name of the file to create is the same as the name of an existing file.</param>
352+
<summary>Retrieves a stream for writing to a file in the specified parent folder.</summary>
353+
<returns>A task that represents the asynchronous write operation.</returns>
354+
<remarks><format type="text/markdown"><![CDATA[
355+
356+
## Remarks
357+
358+
> [!NOTE]
359+
> In Visual Basic and C#, you can call this method as an instance method on any object of type <xref:Windows.Storage.IStorageFolder>. When you use instance method syntax to call this method, omit the first parameter. For more information, see [Extension Methods (Visual Basic)](~/docs/visual-basic/programming-guide/language-features/procedures/extension-methods.md) or [Extension Methods (C# Programming Guide)](~/docs/csharp/programming-guide/classes-and-structs/extension-methods.md).
360+
361+
## Examples
362+
363+
The following example shows how to open a file as a <xref:System.IO.Stream> in a Windows Store app, and write to it by using an instance of the <xref:System.IO.StreamReader> class.
364+
365+
[!code-csharp[windowsruntimestorageextensions#8](~/samples/snippets/csharp/VS_Snippets_CLR_System/system.io.windowsruntimestorageextensions/cs/blankpage4.xaml.cs#8)]
366+
[!code-vb[windowsruntimestorageextensions#8](~/samples/snippets/visualbasic/VS_Snippets_CLR_System/system.io.windowsruntimestorageextensions/vb/blankpage4.xaml.vb#8)]
367+
368+
The next example shows the XAML code that is associated with the previous example.
369+
370+
[!code-xaml[windowsruntimestorageextensions#7](~/samples/snippets/csharp/VS_Snippets_CLR_System/system.io.windowsruntimestorageextensions/cs/blankpage4.xaml#7)]
371+
372+
]]></format>
373+
</remarks>
374+
<exception cref="T:System.ArgumentNullException"><paramref name="rootDirectory" /> or <paramref name="relativePath" /> is <see langword="null" />.</exception>
375+
<exception cref="T:System.ArgumentException"><paramref name="relativePath" /> is empty or contains only white-space characters.</exception>
376+
<exception cref="T:System.IO.IOException">The file could not be opened or retrieved as a stream.</exception>
262377
</Docs>
263378
</Member>
264379
</Members>
265-
</Type>
380+
</Type>

0 commit comments

Comments
 (0)