C# Data Access: Text Files

preview_player
Показать описание

Data access in C# is not really hard, but there is a lot of conflicting information out there. This video will help you clear up how to read from and write to a text file. It doesn't cover every method, just one of the easiest.

0:00 - Intro
0:54 - Creating Demo Console App
1:39 - File path: string literal explained
2:51 - Reading from text file
5:00 - Writing to text file
7:07 - Populate DataModel fields form text file:
9:33 - • Line split
12:20 - • String interpolation
15:24 - Note on data validation when reading form text file
17:45 - Adding object to a list:
18:47 - • Anonymous instance explained
19:45 - List of DataModel to text file
23:22 - Summary and concluding remarks

Thanks Ralfs HBK for the chapter breakdown
Рекомендации по теме
Комментарии
Автор

Thank you so much. The professor I have never makes us code, He always give us a power point presentation and send us home with a lab. It is nice to see someone who takes the time and explain us the code behind the theory.

juannunez
Автор

0:00 - Intro
0:54 - Creating Demo Console App
1:39 - File path: string literal explained
2:51 - Reading from text file
5:00 - Writing to text file
7:07 - Populate DataModel fields form text file:
9:33 - • Line split
12:20 - • String interpolation
15:24 - Note on data validation when reading form text file
17:45 - Adding object to a list:
18:47 - • Anonymous instance explained
19:45 - List of DataModel to text file
23:22 - Summary and concluding remarks

RalfsBalodis
Автор

Can't belive it! 80% of my work is based on text files, move it, make logs about the actions taken, update, read it to valid them, awesome Tim, you get a great way to teach. I am your Fan!! Its pure gold. Thanks so much!

davidramirez
Автор

EXTREMELY helpful. I have been seating at my laptop for 3 hours trying to find how to read and write from text files to make a log-in interface and nothing helped me, except this beauty. Much appreciated!

nothingtosee
Автор

I can't believe how helpful this actually was. I'm actually mind blown by how you managed to convey so much information and clear up a lot of my question so simply. thank you very very much. You're a blessing to humankind

regal_
Автор

Reading from and writing to text files has come in very handy to me.
Thank you, Tim! :)





I've been doing access and security system upgrade at work for a client.
Database form old system was not compatible with the new system, although it was the same manufacturer...

So only option was to re-configure whole system by hand. Lucky for me, old system had a feature to print out programming as csv files.
And new system could take csv in. Only problem was that text files needed to be cleaned up and needed some other work and many manipulations to be usable.
Now with C# I've been flying through text files containing thousands of lines like it was nothing. Filtering, rearranging, creating new lists and other stuff.
New system was ready in no time. So to speak...
These basic techniques has really made my life easier. To give you some kind of reference - we don't use computer programming at work. We work with hardware.
Installation and service. Electronics.
To use C# at work is like using some kind of space age technology. Very exciting!

One may argue, that you could use excel for working with csv... I'd say - excel is limited thou. You can't do stuff with excel like you can with C#.
With C# it's freedom.
Thank you!

RalfsBalodis
Автор

I'm struggle to build a "practising app" when learn C#, don't know how to get data to excute and then save back to. Text file absolutely is easy way. Your video help me much. Hope I've learnt more from your database turorial. Thanks.

mrnhaque
Автор

First of all thanks for refresher. Sometimes if you get lost in c# thing become really complicated than they should be. This is an old video but still so relevant. I just fixed some of my code after watching it. Your video never fail to deliver. I really appreciated your efforts. 👍

mrf
Автор

Tim, that was So well explained!!! Just learning C# in past week after VBA. Storing data is key. You’ve shown me how easy this is and also to understand what’s happening. Thank You!!!

peter-eq
Автор

Amazing! Informative, clear and useful information! Please continue to make these great videos, I appreciate them and thank you for your time in making them!

Almethese
Автор

thank you sir. I spent the whole day manipulating data with jugged arrays, I am giving lists a try.

andrewthebladethrower
Автор

Chuckles. Just keep standing on that "soapbox". The Gospel you sing is very informative and good learning! So don't give up on it, mate.

TheAngelOfDeath
Автор

Finally a programmer with common sense who can teach! Thanks!

jamescaleb
Автор

I believe this is what Facebook used to store plain text passwords. They probably watched your video and thought, "Hey, we can save time by not hashing password in a database, it will be quick." Brilliant.

scientist
Автор

Thank you, your list of string method is very elegant. List processing has come of age compared to multidimensional arrays, which are fine if your a string theory physicist used to thinking in multi dimensions.

shaynemurray
Автор

Awesome and clean explanations especially for us beginners, wish to see more tutorial on delegates, reflection, dependency injection, rest services, more in-depth on unit testing, web api and asp.net mvc

brightndiweni
Автор

That is the easiest and clearest I have ever seen that explained.

FerreusDeus
Автор

No matter where I place the file, and write the file path EXACTLY as i have it structured, the compiler will not find the file and runs an exception. I cant seem to find anything about how to fix this online.
EDIT: Pretty sure that it was reading the file "Test.txt" as "Test.txt.txt". When i removed the ".txt" part of the file name, the program compiled normally. I found that solution on stackoverflow and it helped out. Anyways, it was a naming problem on my end. Sorry for the mix up and thanks for the tutorials :)

novaplum
Автор

Like the way you explain things. You just got a new subscriber. Definetely will watch more!

jankesful
Автор

Thanks Tim. Great tutorial, very clear and concise as with the rest of your tutorials. Keep up the good work!

alandotchin