C# Read and Write to a Text File

  Рет қаралды 122,041

Programming w/ Professor Sluiter

Programming w/ Professor Sluiter

Күн бұрын

Пікірлер: 72
@Joyosagsm
@Joyosagsm 5 жыл бұрын
I don't really have a question I just want to say this was a great video
@mortrem76
@mortrem76 9 ай бұрын
It is a great video
@MUSHIN_888
@MUSHIN_888 3 ай бұрын
Thanks dude, this is exactly what I needed to learn for a lab question in my programming class at uni
@markyrocks69
@markyrocks69 3 жыл бұрын
Very useful video. I'm primarily a c++ user but you can't beat the ui building tools in c#.
@gecko2023
@gecko2023 2 жыл бұрын
honestly, i've been doing coding for about 6 years now, and text files were a sort of, no go topic for me, this honestly made it seem so simple I feel a little stupid xD But in all seriousness, thanks mate, this has helped a lot
@shwetachavan751
@shwetachavan751 9 ай бұрын
Thank you for so easy to understand videos. I had difficulty understanding this topic but after watching this video , I understood the topic very well. Thank you.
@emiledanielbouwer6963
@emiledanielbouwer6963 2 жыл бұрын
Thank you. This was simple, helpful and using the list approach makes the class more versatile.
@Furki4_4
@Furki4_4 2 жыл бұрын
Thank you Prof Sluiter for precise explanation
@InventorDBA
@InventorDBA 3 жыл бұрын
tip for anyone who is watching this: if you are using windows, in file explorer make your text file, click on the "home tab" on top, and click copy path. You don't have to manually copy the path every time.
@mateeeje
@mateeeje 2 жыл бұрын
How to search for it. I have etc. John and he has number one after him and when i enter 1 to display john
@codymckinney4934
@codymckinney4934 Жыл бұрын
i do this, but wondering whats the pros and cons to stream reader vs this
@smoua4588
@smoua4588 3 жыл бұрын
Thank you so much Professor Sluiter
@FileFN3
@FileFN3 Жыл бұрын
I have a problem with the code : My file name and path are correct but it says it can not find it
@alshentec2286
@alshentec2286 2 жыл бұрын
Do you have any tricky ways to save txt file as different names such as 123 while theere is already a txt file as that one thanks for your video
@kooyoung4866
@kooyoung4866 3 жыл бұрын
how do i delete words on the text instead of writing to it ?
@jonlbs7
@jonlbs7 4 жыл бұрын
EXCELLENT !!! One of the best on just what I was looking for. 😊👍👌👍
@thelinguafranca5421
@thelinguafranca5421 3 жыл бұрын
Hello, how can I return a specific line in all lines. Tnx
@tprnbs
@tprnbs 2 жыл бұрын
Great tutorial! is it the same as using StreamReader/StreamWriter? Thanks!
@kellothermes5090
@kellothermes5090 2 жыл бұрын
It's only showing FileNotFoundException . How should I resolve this exception ?
@shadsluiter
@shadsluiter 2 жыл бұрын
It could be that the file is named differently than what it appears. Check to see that file extensions are visible on your computer. The file may be called filename.txt.txt instead of filename.txt
@kellothermes5090
@kellothermes5090 2 жыл бұрын
@@shadsluiter Thank you , that was exactly what was happening.
@aravindswamy4742
@aravindswamy4742 3 жыл бұрын
Nice video. How will you bind the data for an employee registration form on the each text box that is named accordingly? When I tried doing the data binding, all the datas are binded on a single text box?
@yoshikiyamaguchi5295
@yoshikiyamaguchi5295 5 жыл бұрын
I have a question. After I read the textfile, if I wanted to write the same thing in a different format, how could I do that? For example, now my textfile says 116 11/2/2012 18:22 N9 45.483 E10 30.495 416 m Now I want to write them to another file in the following manner 116, 11/2/2012 18:22, N9 45.483 E10 30.495, 416m How could I make it so that all the information are lined up in one line, and separate them with " , " ?
@shadsluiter
@shadsluiter 5 жыл бұрын
You can join strings in C# very easily. Here is a good page to explain it docs.microsoft.com/en-us/dotnet/csharp/how-to/concatenate-multiple-strings
@frab8061
@frab8061 5 жыл бұрын
I have a question, at the ending you're adding jon doe to the list and then writing the list to the file. But the other names were already in there. I thought there have to be the names from before plus the names from before again plus jon doe. Why is this not the case? Does the content of the file getting overwritten with File.WriteAllLines?
@shadsluiter
@shadsluiter 5 жыл бұрын
Each time we run the program we do this (1) read all lines (2) add John Doe to the list of names (3) write the list back to the file. The file is overwritten each time. There is an option to the writeAllLines() method to either append or overwrite the file. Overwrite is the default choice if no parameter is provided. Check out the docs on the method here docs.microsoft.com/en-us/dotnet/api/system.io.file.writealllines?view=netframework-4.8
@calvinking3355
@calvinking3355 2 жыл бұрын
Having an issue where filepath is denied access. I've tried it on multiple text files and still receive the same problem. The program reads the file just fine. It just doesn't write to it. Saw other people were experiencing the same thing was hoping for a quick fix. Using VS 2019 CE.
@calvinking3355
@calvinking3355 2 жыл бұрын
I fixed it. While the problem is common, the solution is not so much. Those who come across this problem, leave a reply and I'll share my fix.
@deathvaisen6381
@deathvaisen6381 2 жыл бұрын
@@calvinking3355 How to fix it man
@calvinking3355
@calvinking3355 2 жыл бұрын
@@deathvaisen6381 I just created a new folder through VS2020E. That will allow you to read and write only to the folder that was created through the program. Basically, my CPU didn't acknowledge permissions so reading/editing/appending were confined to the program's own environment. Hope that helps!
@vusivuyanithemba797
@vusivuyanithemba797 3 жыл бұрын
You are the best, I am going to be a good C# programmer soon
@shadsluiter
@shadsluiter 3 жыл бұрын
Good to hear. How is your plan working out so far?
@pje_
@pje_ 3 жыл бұрын
How to read and write to EXE FILE?
@parsaabdolhossaini3978
@parsaabdolhossaini3978 3 жыл бұрын
great video, I learned something new today
@shadsluiter
@shadsluiter 3 жыл бұрын
Glad you liked it!
@magmyr
@magmyr 4 жыл бұрын
Hello Shad, thanks for a well explained video! I have one question thought, when i try to run my program to read the text file it throws me an error of access denied. Any idea how can i fix that? Thanks in advance!
@cossinle
@cossinle 4 жыл бұрын
Try running your application as adminstrator.
@magmyr
@magmyr 4 жыл бұрын
@@cossinle still get the same error. Any possible solutions i could try?
@magmyr
@magmyr 4 жыл бұрын
I fixed the problem. Thanks for the help!
@MaybeKian
@MaybeKian 4 жыл бұрын
@@magmyr why cant you say how you fixed it? there are ppl who have the same problem.
@hrishikeshgarud7177
@hrishikeshgarud7177 4 жыл бұрын
@@magmyr how
@douglasposho9299
@douglasposho9299 3 жыл бұрын
Keep up the good work
@randomtopicvideos3957
@randomtopicvideos3957 4 жыл бұрын
Can you help me, i have this error, System.UnauthorizedAccessException,how should i fix this
@equation1321
@equation1321 4 жыл бұрын
staccoverflo
@thedude4039
@thedude4039 4 жыл бұрын
Perhaps the location of the file is not accessible by the user you are using on your computer. Try making whichever outlook account you are signed onto your computer as, admin. If this doesn't work, idk. If you're on mac, idk.
@OpTicMatrixJ
@OpTicMatrixJ 4 жыл бұрын
Great video sir thank you!!!
@kacper2246
@kacper2246 4 жыл бұрын
what does the @ before the string mean?
@pedro2mnunes
@pedro2mnunes 4 жыл бұрын
The @ character specifies a string as a verbatim literal string. In this way you can use characters like \ without escape characters.
@kacper2246
@kacper2246 4 жыл бұрын
@@pedro2mnunes that is actually very useful, thanks :)
@Noah.Nation
@Noah.Nation 2 жыл бұрын
Doesn't work :/
@umairjamshaid2173
@umairjamshaid2173 4 жыл бұрын
Super helpful. Thanks alot
@TonyDaExpert
@TonyDaExpert 4 жыл бұрын
I hope this is helpful making something in c# where I want to store an id and a date on a file line. With c++ (my native programming language) I could just get a for loop to go over each line and directly copy the set amount of values within each line into different variables (separate for ID and date) within an array
@bharanivasanthbca4756
@bharanivasanthbca4756 3 жыл бұрын
Tanx for the information
@minetomek
@minetomek 4 жыл бұрын
Thanks for info. :)
@haydenstuteville9423
@haydenstuteville9423 5 жыл бұрын
It didn't show me my combos (my list) it just showed alot of system.string stuff can you help?
@shadsluiter
@shadsluiter 5 жыл бұрын
Perhaps you need a toString() method defined in the class/object you are trying to display. Here is a good link to explain it kzbin.info/www/bejne/iorWmoOVoZqMqck
@nynthes8488
@nynthes8488 2 жыл бұрын
thanks bush
@adamloepker8057
@adamloepker8057 3 жыл бұрын
saved me from a less than effective class cession
@jonlbs7
@jonlbs7 4 жыл бұрын
Where's the next one? You mentioned "in a future video .." and then I can't find it..
@davidheizer6232
@davidheizer6232 3 жыл бұрын
kzbin.info/www/bejne/e4qaepd4edFnhqs
@Wonglamai
@Wonglamai 4 жыл бұрын
thank you
@palkay875
@palkay875 3 жыл бұрын
Good video thx
@debprosad6890
@debprosad6890 3 жыл бұрын
nice
@exile3965
@exile3965 4 жыл бұрын
Good video thanks
@shadsluiter
@shadsluiter 4 жыл бұрын
So nice of you
@exile3965
@exile3965 4 жыл бұрын
shad sluiter your welcome dude
@BKadezabek
@BKadezabek 4 жыл бұрын
Thanks :D
@mqrvmckl3504
@mqrvmckl3504 4 жыл бұрын
Very helpfull
@brockbillings4299
@brockbillings4299 4 жыл бұрын
Great video, but on a completely unrelated note this guy looks so much like kronos from god of war
@legohexman2858
@legohexman2858 3 жыл бұрын
Maybe he is kronos
@sagarwalishetti1176
@sagarwalishetti1176 4 жыл бұрын
Thank you
C# file io 02 read to objects
6:49
Programming w/ Professor Sluiter
Рет қаралды 18 М.
Working With The File System in C# - Managing Folders and Files
35:07
Chain Game Strong ⛓️
00:21
Anwar Jibawi
Рет қаралды 41 МЛН
Master Pointers in C:  10X Your C Coding!
14:12
Dave's Garage
Рет қаралды 335 М.
My 10 “Clean” Code Principles (Start These Now)
15:12
Conner Ardman
Рет қаралды 305 М.
C# Data Access: Text Files
24:34
IAmTimCorey
Рет қаралды 269 М.
The Absolute Best Intro to Monads For Software Engineers
15:12
Studying With Alex
Рет қаралды 675 М.
Reading and Writing to Text Files With StreamReader and StreamWriter in C#
9:35
Dependency Injection, The Best Pattern
13:16
CodeAesthetic
Рет қаралды 900 М.
31 nooby C++ habits you need to ditch
16:18
mCoding
Рет қаралды 841 М.
Creating Excel Files in C#
55:42
IAmTimCorey
Рет қаралды 129 М.