1. iterate the row of the fileCopy codeThe Code is as follows:Public static IEnumerable {Using (TextReader reader = File. OpenText (fileName )){String line;If (line = reader. ReadLine ())! = Null){Yield return line;}}}Static void Main (){Foreach (string line in Iterator. ReadLines ("")){Console. WriteLine (line );}}2. Use the iterator and predicate to filter rows in the file.Copy codeThe Code is as follows:Public static IEnumerable {If (source = null
This article provides a detailed analysis of file traversal information using the iterator. For more information, see
This article provides a detailed analysis of file traversal information using the iterator. For more information, see
1. iterate the row of the file
The Code is as follows:
Public static IEnumerable
ReadLines (string fileName)
{
Using (TextReader reader = File. OpenText (fileName ))
{
String line;
If (line = reader
support for Text.
· AppendText: append text to an existing file.· CreateText: Creates or opens a new file for writing text.· OpenText: open an existing text file for reading.
But the above method mainly on the UTF-8 encoding text operations, which is not flexible enough. We recommend that you use the following code to operate the txt file.· Read the txt file. The sample code is as follows:
StreamReader TxtReader = new StreamReader (@ "c: \ tempupload
Example of file operations in ASP. NET (VB)Post: Andy. m Date: popularity: 60
Example of file operations in ASP. NET1. Write filesWritefile. aspxResponse. Write ("writing the content into text file in ASP. NET Dim strwriterobj as streamwriter 'declares a streamwriter objectStrwriterobj = file. createtext ("C:/aspnet.txt") 'creates a text file and assigns it to the streamwriter object.Strwriterobj. writeline ("Welcome to wonderfull world of ASP. NET programming ")'Write content to the fi
files are not prompted for installation. If you find that a library file is not installed, it is possible that the network is bad or the download source is missing. This time the user uses acommand to update download source under”apt-get Update, and then execute the two scripts above. For example, as shown, run again“./install-devel-packages.sh"After that, the prompt does not installLibraries and software, then the installation is complete. reducedGccversionUseUbuntucompilingAndroidneeds to be
as follows:
if (File.exists (@ "C:\tempuploads\newFile.txt"))//Determine if the file exists
{
CopyFile (); Copying files
DeleteFile (); deleting files
MoveFile (); Moving files
}
Else
{
MakeFile (); Generating files
OpenFile (); Open File
Setfile (); Set file properties
}
In addition, the file class provides more support for text literals.
· AppendText: Append text to an existing file
· CreateText: Create or open a new file for writing text
·
Read
You can read data from a file.
ReadWrite
You can read data from one file and write data to the file.
Write
You can write data to the file.
The following code shows how the open () method is used.
FileInfo f = new FileInfo ("F:/myfile.txt");
FileStream s = F.open (Filemode.openorwrite, FileAccess.Read);
using StreamReader class and StreamWriter class to implement file read and write operation
Read and write to
should create a new file.
Open
Specifies that the operating system should open an existing file.
OpenOrCreate
Specifies that the operating system should open the file (if the file exists), otherwise, create a new file.
Truncate
Specifies that the operating system should open an existing file. Once the file is opened, it will be truncated to a size of 0 bytes.
Of course, you can also use (Open, OpenRead, OpenText, Openwrite) to create FileStream
Dim F
(); Moving files}Else{MakeFile (); Generating filesOpenFile (); Open FileSetfile (); Set file properties}In addition, the file class provides more support for text literals.· AppendText: Append text to an existing file· CreateText: Create or open a new file for writing text· OpenText: Open an existing text file for readingBut the above method mainly carries on the operation to the UTF-8 encoded text, thus appears insufficiently nimble. Here the reade
/block block above, which uses the StreamWriter class to write a simple string in a temporary file:
//向临时文件中写入数据 StreamWriter* writer = File::AppendText(fileName);writer->WriteLine("A test sample data");writer->Flush();writer->Close();
The data written can be read through the following StreamReader, where the contents of the entire file are read into a string object:
StreamReader* reader = File::OpenText(fileName);
Finally, after using the tempora
17.3.1 read and write in text mode
The SteamReader and StreamWriter classes provide a way for us to read and write data in text mode. The following example reads the content from a text file and prints it on the screen.
Program Listing 17-5:
Using System;
Using System.IO;
Class Filetest
{public
static void Main ()
{
StreamReader srd;
try{
srd=file.opentext ("C:\\c#\\file1\\file1.txt");
}
Catch
{
Console.WriteLine ("File Open Failed");
return;
}
while (SRD. Peek ()!
policies or events, catalyze or destroy it?D, competitor strength directly verified the market capacity and eco-circle situation, in the current site resources on the basis of the current situation, we have enough strength to compete with competitors? (Of course, some Internet applications are non-profit applications, there are no competitors!) )E, Web site investment scale and business objectives are affe
SEO Tutorial: Target keyword Analysis
If you want to rank well with specific keywords, especially competitive keywords, you can go to it's old-fashioned way and try to get anyone to contact, you can slowly elevate the ranking ladder. Alternatively, you can use these high power technologies to quickly gain authority in the eyes of Google.
Study your competitors and get a link from the top 100 sites linked to them.
Google search your keywords
We do a lot of website keywords often have this feeling, that is the beginning of the key words can progress quickly, but to a certain ranking often will stop before, even if the brain to optimize also has no good effect, as if it is in the state of the stalemate, when this situation occurs when what to do? is to retreat from the array or find another way out, the author introduces several ways to solve this state!
One: Analysis of the characteristics of the state of stalemate
Generally when y
inevitably click.
For example: Title: Where to find the complete set of Liu MV, then we list the contents of the Liu MV complete name is what and tell users in the cool dog can find the complete Liu MV, and we provide cool dog 2013 download address anchor text link, then users will click to download.
(2) Content blank
We first of our industry users of common needs are listed, and then we see which some areas exist gaps in our industry may have content blank, that is, users have demand but th
The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion;
products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the
content of the page makes you feel confusing, please write us an email, we will handle the problem
within 5 days after receiving your email.
If you find any instances of plagiarism from the community, please send an email to:
info-contact@alibabacloud.com
and provide relevant evidence. A staff member will contact you within 5 working days.