Skip to content

Commit

Permalink
Update snippets per issue. (#37793)
Browse files Browse the repository at this point in the history
* Update snippets per issue.

* Add project file.

* Troubleshoot snippet build error.

* Troubleshoot snippet error.
  • Loading branch information
TimShererWithAquent authored Oct 31, 2023
1 parent e5bd2e8 commit 5c6e7bf
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 15 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>net6.0</TargetFramework>
<Nullable>enable</Nullable>
<ImplicitUsings>enable</ImplicitUsings>
<StartupObject>CompBuf</StartupObject>
</PropertyGroup>

</Project>
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,8 @@ public static void Main()
Console.WriteLine($"{FILE_NAME} does not exist!");
return;
}
FileStream fsIn = new FileStream(FILE_NAME, FileMode.Open,
FileAccess.Read, FileShare.Read);
// Create an instance of StreamReader that can read
// characters from the FileStream.
using (StreamReader sr = new StreamReader(fsIn))
// Create an instance of StreamReader characters from the file.
using (StreamReader sr = new StreamReader(FILE_NAME))
{
string input;
// While not at the end of the file, read lines from the file.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,18 +13,19 @@ public static void Main()
Console.WriteLine($"{FILE_NAME} does not exist.");
return;
}
FileStream f = new FileStream(FILE_NAME, FileMode.Open,
FileAccess.Read, FileShare.Read);
// Create an instance of BinaryReader that can
// read bytes from the FileStream.
using (BinaryReader br = new BinaryReader(f))
using (FileStream f = new FileStream(FILE_NAME, FileMode.Open, FileAccess.Read, FileShare.Read))
{
byte input;
// While not at the end of the file, read lines from the file.
while (br.PeekChar() > -1 )
// Create an instance of BinaryReader that can
// read bytes from the FileStream.
using (BinaryReader br = new BinaryReader(f))
{
input = br.ReadByte();
Console.WriteLine(input);
byte input;
// While not at the end of the file, read lines from the file.
while (br.PeekChar() > -1)
{
input = br.ReadByte();
Console.WriteLine(input);
}
}
}
}
Expand Down

0 comments on commit 5c6e7bf

Please sign in to comment.