HTML tutorial
CSS3 tutorial
Bootstrap tutorial
JavaScript tutorial
JQuery tutorial
AngularJS tutorial
React tutorial
NodeJS tutorial
PHP tutorial
Python tutorial
Python3 tutorial
Django tutorial
Linux tutorial
Docker tutorial
Ruby tutorial
Java tutorial
C tutorial
C ++ tutorial
Perl tutorial
JSP tutorial
Lua tutorial
Scala tutorial
Go tutorial
ASP.NET tutorial
C # tutorial
This chapter describes the knowledge about working with text files.
In the previous chapter, we have learned that web page data is stored in the database.
You can also put the site data is stored in a text file.
Text used to store data files are commonly called flat files. Common text file format is .txt, .xml and .csv (comma separated values).
In this chapter, you will learn to:
In the following example, you will need a text file.
On your website, if no App_Data folder, create one. In the App_Data folder, create a file named Persons.txt of.
Add the following to the file:
The following example demonstrates how to display data in a text file:
Use Server.MapPath find the exact path to the text file.
Use File.ReadAllLines open the text file and reads the file into an array of all rows.
Data array for each row of data in a data item is displayed.
Use Microsoft Excel, you can save a spreadsheet as a comma-delimited text file (.csv file). In this case, each row in the spreadsheet is saved as a text line, each data column separated by commas.
in the example above can be used to read a Excel .csv file (just the name of the file name into the corresponding Excel files).