????? ????? ??? ??? ???????? System.IO ? Visual C#

?????? ????????? ?????? ?????????
???? ???????: 306777 - ??? ???????? ???? ????? ????? ??? ???????.
?????? ??? ????? Microsoft Visual Basic .NET ?? ??? ???????? ???? 302309.

???? ??? ??????? ??? ?????? ????? Microsoft .NET Framework ??? ????? ???????:
  • System.IO
  • System.Collections
????? ???? | ?? ????

?? ??? ??????

??????

???? ??? ??????? ???? ????? ??? ????? ??????? ??????? ?? ??? ??? (.txt) ?? ?????? ????? ArrayList ???? ??? ????????? ??? ????????.

???????

Microsoft Visual C#

????? ??????? ?????? ?? "Visual C" #

??? ????? ????? ????? ??????? ??? ??? ?? ???????/??????? (IO) ???????? ??? ??? ?? ??? ?? ???? ??? ??????? ??? ????? ???????. ???? ??? ?????? ????? ??????? ????? ?? ??? ????? ??????? ?????? ???? ??? ?????? ?? ??? ??????? ????????. ?????? ??? ?????? ?? ?????? ?? ????? ???????? ?? ??? ?????.

??? ????? ?? ??? ????? ?????? ?? ????? ?????? ?????? ??????? ??????? ?? ????? ? ????? ArrayList ?? ???? ???? ?????????. ???? ?? ????? ?? ????? ?????? ??? ?????? ???????? ?? ????? ????? System.IO ??? System.IO.StreamReader ???? ???.

?????? ????? ??? ?????? ??? ????? ??? ??? (.txt) ???? ??? ?????.

????? ????? ??? ??? ?? "Visual C" # ???? ??????? ???????:
  1. ??? ????? Microsoft Visual Studio.
  2. "?????" ????? ???? ???? "???? ??" Visual C "#. ???? Visual Studio ??? ??????? ??? ?? ????? Main() ????.
  3. ???? ?? ?? ??????? ???? ????? ????? ??? ??????. ?????? ??????? ???????? ??? ?????? ????? ????System.IO ? System.Collections ???? ??? ?????? ????? ????????? ?? ?????? ??????? ??? ???? ??? ?? ????????? ???????? ?????? ??. ??? ??????? ??? ???????? ???
    using System;
    using System.IO;
    using System.Collections;
    					
  4. ???? ??? ??????? ?????? ???? ???? ?? ?????? StreamReader ?? ????? ???? ????? ??? ??????? ??? ???:
    StreamReader objReader = new StreamReader("c:\\test.txt");
    					
  5. ??? ?? ???? ???? ????? ????? ?????? ?? ??? ?? ????? ????? ??????. ??? ???? ??? ??? ????? ??? ?????? ArrayList ? ???? ?????? ?????? ???? ??? ??? ?????.
    string sLine="";
    ArrayList arrText = new ArrayList();
    					
  6. ???? ??? ??? ????? ????? ?? ? ??? ?? ??? ??????? ReadToEnd ???? ???? ?? ????? ?????? ?? ?? ????. ??? ???? ??? ???? ??????? ????? ??????? ??????? ReadLine ?????? ?? ??? ???? ?? ????? ?? ??? ???????. ??? ?????? ??? ????? ????? ??? ??????? ?????? ???? ????? ???? ????? ????? ???? ????? ??. ????? ????? ?? ??? ?? ????? ????? ??????? ??????? AddArrayList ?????? ?????? ??? class. ArrayList
    while (sLine != null)
    {
    	sLine = objReader.ReadLine();
    	if (sLine != null)
    		arrText.Add(sLine);
    }
    objReader.Close();
    					
  7. ?????? ???? For ?? ?????? ??????? ???? ?????? ArrayList ??? ???? ?????? ??? ???:
    foreach (string sOutput in arrText)
    	Console.WriteLine(sOutput);
    Console.ReadLine();
    					
  8. ??? ?????? ????????? ???????? ?????? ?? ???? ????? ????? ????? ??? ???? ??????.

????? ??? ????????? ????????

using System;
using System.IO;
using System.Collections;

namespace TextFileReader_csharp
{
	/// <summary>
	/// Summary description for Class1.
	/// </summary>
	class Class1
	{
		static void Main(string[] args)
		{
			StreamReader objReader = new StreamReader("c:\\test.txt");
			string sLine="";
			ArrayList arrText = new ArrayList();

			while (sLine != null)
			{
				sLine = objReader.ReadLine();
				if (sLine != null)
					arrText.Add(sLine);
			}
                        objReader.Close();

			foreach (string sOutput in arrText)
				Console.WriteLine(sOutput);
			Console.ReadLine();
		}
	}
}
				

??????? ??????? ????????

???? ????? ????? ??? ?? ???? ??? ??? ??? ????? ?? ????? I/O ??? ?? ??? ??????? ???????:
  • ?? ??? ?????? ??? ???, ???? ?????? ?? ?? ???? ??? ?????? ????? ???? ????? ??????? ?? ??????? ?? ?? ???? ??? ?????????.
  • ??? ?????? ?????? ????? ?????? ??? ??????? ??? ?? ???? ??????? ?????. ?? ????? ???? ???? ??? ????? ???? ???? ???????? ???????? ?? ??????? ?? ?? ?? ???? ???? ?????? ?????? ??? ?????.
????? ?? ?? ??? ??????? ?? ???? ??????? ???? ???. ?? ?????? ????? ?????? ???? ???? ???????? ??????? ??? ???????? ???????.

???????

???? ???????: 306777 - ????? ??? ??????: 15/?????/1428 - ??????: 2.6
????? ???
  • Microsoft Visual C# 2005
  • Microsoft Visual C# .NET 2002 Standard Edition
  • Microsoft Visual C# 2008 Express Edition
????? ??????: 
kbmt kbcollections kbhowtomaster kbio KB306777 KbMtar
????? ????
???: ??? ????? ??? ?????? ???????? ?????? ????? ???? ????? ?????????? ????? ?? ????????? ?????? ????. ???? ???? ?????????? ???? ?? ???????? ???????? ?????? ????????? ????? ????????? ???????? ????? ???????? ?????? ?? ?????? ??? ?? ???????? ???????? ?? ????? ??????? ?????? ??? ??????? ?????? ??. ?????? ?? ???? ??? ??????? ???????? ????? ?? ???? ????? ?????? ??? ????? ??? ????? ??????? ?? ????? ?? ?????? ??? ??? ??????? ??????? ?? ????? ????? ????? ????? ?????. ?? ????? ???? ?????????? ??????? ??? ????? ?? ??????? ?? ????? ?????? ?? ??? ????? ?? ????? ??????? ?? ???????? ?? ??? ???????. ???? ???? ?????????? ???????? ??? ????? ?????? ??????? ??????
???? ??? ????? ??????? ?????? ??????????306777

????? ???????

 

Contact us for more help

Contact us for more help
Connect with Answer Desk for expert help.
Get more support from smallbusiness.support.microsoft.com