Skip to content

FileStream example bug #4141

Closed
Closed

Description

@malghabr

Hi,

Not sure if this is considered a bug but the first example on the FileStream docs only works if you have a file with less than 1024 bytes or bytes%1024 == 0. This is due to the buffer byte array being reused.
If you use a 4 byte array and try read the string "hello" you end up with the following in the buffer
loop iteration 0: hell
loop iteration 1: oell

hell
oell
This is because the byte array holds data from the first loop
https://docs.microsoft.com/en-us/dotnet/api/system.io.filestream?view=netframework-4.8

Activity

  1. added
    untriaged
    on Apr 20, 2020
  2. added
    Pri3
    on Nov 11, 2020
  3. GSPP commented on Feb 5, 2022

    @GSPP

    What a weird example anyway. So random, what's the idea behind it? Reminds me of the socket documentation.

  4. jozkee commented on Mar 10, 2022

    @jozkee
    Member

    Yes, it is a bit silly. Feel free to send a PR to propose an improved snippet.

    Here's where you can find the snippets of the current ones:

    :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/FStream Class/CPP/fstream class.cpp" id="Snippet1":::
    :::code language="csharp" source="~/snippets/csharp/System.IO/FileStream/Overview/fstream class.cs" id="Snippet1":::
    :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/FStream Class/VB/fstream class.vb" id="Snippet1":::

  5. added
    help wanted
    and removed
    untriaged
    on Mar 10, 2022
  6. malghabr commented on Mar 16, 2022

    @malghabr
    Author

    Sure I can pick this up when i have time

  7. added this to the Backlog milestone on Aug 9, 2022
  8. added 3 commits that reference this issue on Oct 22, 2022
    27c9283
    b017ccc
    b054d8c
  9. added a commit that references this issue on Oct 24, 2022
    01cefbe
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Pri3area-System.IOhelp wanted

    Type

    No type

    Projects

    No projects

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions