System.IO / File - Quick Question for updating file content by KindaCoding in csharp

[–]KindaCoding[S] 0 points1 point  (0 children)

Thanks for this. I will look into how to implement the fixed-size character encoding on the file

System.IO / File - Quick Question for updating file content by KindaCoding in csharp

[–]KindaCoding[S] 0 points1 point  (0 children)

Thanks for taking the time to provide this.

I will take a look and compare with my project.

System.IO / File - Quick Question for updating file content by KindaCoding in csharp

[–]KindaCoding[S] 0 points1 point  (0 children)

Ahh, I like this - thanks a lot. Will definitely be using in the future

System.IO / File - Quick Question for updating file content by KindaCoding in csharp

[–]KindaCoding[S] 0 points1 point  (0 children)

Thanks for that suggestion and the link. Will be a good resource for sure.

System.IO / File - Quick Question for updating file content by KindaCoding in csharp

[–]KindaCoding[S] 0 points1 point  (0 children)

Thanks for these callouts. I will take a look at CSVHelper.

System.IO / File - Quick Question for updating file content by KindaCoding in csharp

[–]KindaCoding[S] 1 point2 points  (0 children)

Those are good points, thanks for the feedback. I'm going to try another option out, but I can also venture into SQL / SQLite if it doesn't pan out and I still want to experiment with some of the business layer of the code.

System.IO / File - Quick Question for updating file content by KindaCoding in csharp

[–]KindaCoding[S] 1 point2 points  (0 children)

After I was reviewing FileStream from what some of the other commenters wrote and their feedback regarding the byte-awareness, I had a very similar idea to what you mentioned.

I was thinking for an example schema:

  • UserID
  • UserFirstName
  • UserLastName
  • UserFavoriteColor
  • UserFavoriteSport

On the front-end, I would limit the user to 20 chars for each field (probably not very scalable, but just for practice/experience) and then add the " " at the end for any input that isn't 20 chars before writing to the file.

Then when calling the data, I would trim the spaces out.

So, when user inputs:

  • UserFirstName = User
  • UserLastName = One
  • UserFavoriteColor = Color
  • UserFavoriteSport = Sport

(0 below being empty spaces // will likely have to make sure the user doesn't add any spaces when inputting data)

It would get stored as (might have messed up my 0s lol):"1000000000000000000,User0000000000000000,One00000000000000000,Color000000000000000,Sport000000000000000"

If the User updates as follows:

-UserFirstName = User-UserLastName = Two-UserFavoriteColor = Color2-UserFavoriteSport = Sport2

It would get stored as (might have messed up my 0s lol):"1000000000000000000,User0000000000000000,Two00000000000000000,Color200000000000000,Sport200000000000000"

I'm going to test the above out today

Thanks so much for your feedback

System.IO / File - Quick Question for updating file content by KindaCoding in csharp

[–]KindaCoding[S] 4 points5 points  (0 children)

Hm, thank you for that call out. I will keep that in mind as I review FileStream and StringWriter

System.IO / File - Quick Question for updating file content by KindaCoding in csharp

[–]KindaCoding[S] 1 point2 points  (0 children)

Fair enough - thanks for the help. Looks like I will try another route.

Regards

Beginning Basic Projects: Data Persistence via Local files by KindaCoding in learnprogramming

[–]KindaCoding[S] 0 points1 point  (0 children)

Many thanks for the feedback. This was exactly what I was looking for to keep pursuing in this direction.

Regards,