Input and Output in .NET - PowerPoint PPT Presentation

About This Presentation
Title:

Input and Output in .NET

Description:

Title: Input and Output in .NET Author: Svetlin Nakov Description: Programming for the .NET Framework http://www.nakov.com/dotnet-project/ Last modified by – PowerPoint PPT presentation

Number of Views:163
Avg rating:3.0/5.0
Slides: 59
Provided by: Svet86
Learn more at: https://www.devbg.org
Category:
Tags: net | input | output

less

Transcript and Presenter's Notes

Title: Input and Output in .NET


1
(No Transcript)
2
???? ? ????? ?.NET Framework
???????????? ?? .NET Framework
http//www.nakov.com/dotnet/
??????? ?????
?????????? ???????? ?? ?????????? ?? ???????
academy.devbg.org
3
?????????? ??????
  • ?????? ???????? ?? ?????? ??????? ?? ?????? ?
    .NET (Common Type System)
  • ?????? ???????? ?? ????? C
  • ?????? ???????? ?? ?????????? ?? ??????? ?
    ????????? ? .NET Framework
  • ?????? ???????? ?? ??????? ???????

4
?????????? (1)
  • ????? ????????????? ?????????
  • ???????? ? .NET Framework. ?????? ? ????????
    ??????. ??????? ????????
  • ????? System.IO.Stream
  • ?????????? ??????
  • ??????? ??????
  • ????? ? ??????
  • ??????? ????? ? ??????
  • ???????? ????? ? ??????
  • ???????? ? ???????. ??????? File ? FileInfo

5
?????????? (2)
  • ?????? ? ??????????. ??????? Directory ?
    DirectoryInfo
  • ?????????? ?? ????????? ??????? ?
    FileSystemWatcher
  • ?????? ? IsolatedStorage

6
????? ????????????? ?????????
  • ???????????? "?????" ? ????????? ????? ??
    ????????????? ?? ??????-??????? ????????? ?
    ???????????? ???????-??????????? ????? (C, C,
    Java, Delphi)
  • ????????
  • ?? ????????? ????? ?? ???????
  • ????????????? ?????????? ?????? ?? ?????, ??
    ????? ???????? ?? ??????????? ??????????????
  • ??????????? ????????? ?? ?????? ? ?????? ??
    ???????? ??????? ?? ? ??? ?????????? ??
    ?????????? ??? ?????? ?? ?????
  • ? .NET Framework ???????? ??????-??????? ????????
    ????????? ??????

7
?????? ??????
// ???????? ?? ??????? ??????? ???? ?????? static
void Main() using ( FileStream
inFile new FileStream( "input.bin",
FileMode.Open), outFile new
FileStream( "output.bin",
FileMode.Create)) byte buf new
byte4096 while (true)
int bytesRead
inFile.Read(buf, 0, buf.Length) if
(bytesRead 0) break
outFile.Write(buf, 0, bytesRead)

8
???????????? 1
  • ???????? ?? ??????? ????

9
???????? ? .NET Framework
  • ? .NET Framework ???????? ?? ??? ????
  • ?????? ?????? (base stream)
  • ????? ? ????? ????? ?? ? ??? ?????? ????????? ??
    ?????????? ?? ?????
  • ??????? FileStream, MemoryStream, NetworkStream
  • ???????? ?????? (pass-through streams)
  • ????? ? ????? ? ????? ??????, ???? ???????
    ???????????? ?????????????? (????. ??????????,
    ???????? ? ????????????)
  • ???????? BufferedStream ? CryptoStream

10
???????? ? .NET Framework
  • ????????? ???????? ? ?????? ??
  • ???????????? (?????????)
  • ??????? ?? ??????? ? ????????? ?? ??????/
    ?????????? ?? ????? ??? ? ???? ?????
  • ???? ????????? ? ???????????? ?? ????? ?? ??????
    ?????????? ?? ???? ?????????
  • ???????? ??? ?????? ????? ?? ??????? ??? ?? ????,
    ? ??? ????? ????? ????????? ???
  • ??????
  • ???????? ?? ????? ?? ??????
  • ? ?????????? ?? ???? ?? ?????? ???? ????? ??
    ???????? ?? ???????? ?????
  • ???????? ??? ?????? ????? ??????? ?? ???????? ??
    ???????? ??????? ??? ?????

11
???????? ? .NET Framework
  • ????????? ???????? ? ?????? ??
  • ??????
  • ???????? ?? ????? ? ??????
  • ? ?????????? ?? ???? ?? ?????? ???? ????? ??
    ???????? ?? ???????? ?????
  • ???????? ??? ?????? ??? ???? ??????? ?? ????????
    ??? ????? ?? ???????? ???????
  • ?????????????
  • ????????? ???????? ??????? ?? ?????? (??? ??
    ???????? ?????????????)
  • ??????????????? ????? ?????? ???????? ???????,
    ???????? ??? ???? ?? ??????
  • ???????? ??? ?????? ????? ?? ??????? ????????
    ??????? ??? ?????

12
???????? ? .NET Framework
  • ????????? ???????? ? ?????? ??
  • ?????????
  • ???????? ?? ???????? ? ?????? ? ?? ????????????
    ???????????? ???????
  • ???????? ??? ?????? ????? ?? ???????? ??????? ??
    ?????????? ??????, ????? ?? ?? ??? ??? ????????
    ?? ????? ? ?? ??????? ?????
  • ????? ????????
  • ?????????? ?? ?????????? ?????? (flush)
  • ???????? ?? ? ?????????? ?????? ? ?????? (?????
    ?? ?????????? ? ?????? ?? ?????? ? ????? ?
    ?????????????)
  • ????? ????????? ?????? ????????? ? ?????
    ?????????? ?? ??? ????????

13
???????? ? .NET Framework
  • ????? ???? ?? ?????? ?????? ? ???????????? ????
    System.IO.Stream
  • ? ???? ?? ?????????? ?????? ?? ?????????? ??
    ????????? ????????
  • ?? ?????? ?????? ????????? ?????????? ??????,
    ?????? ? ?????????????
  • ??? ???????? ?? ????????? ???? ?? ?? ??????? ????
    ?????????? CanRead, CanWrite ? CanSeek
  • ????????, ????? ?????????? ?????????????
    ????????? ???????? Position ? Length
  • ??? ????????? ????? Stream.Null, ????? ????????
    ?????? ????? ?? ?????? ? ??????

14
????? System.IO.Stream
  • ??-????? ?????? ?? ????? Stream
  • int Read(byte buffer, int, offset, int count)
    ???? ???-????? count ????? ?? ?????? ?????,
    ????????? ???????? ??????? ? ????? ????? ????? ?
    ?????? ??? 0 ??? ???? ?? ??????
  • Read() ???? ?? ??????? ?? ???????????? ?????
    ?????? ??????? ???? 1 ????
  • Read() ???? ?? ??????? ??-????? ?? ???????? ????
    ???????
  • Write(byte buffer, int, offset, int count)
    ??????? ? ?????? ???????? ?? count ?????,
    ?????????? ?? ?????? ??????? ? ?????
  • Write() ???? ?? ??????? ?? ???????????? ?????,
    ?????? ??????? ?????? ??????? ???
    ????????????????? ??

15
????? System.IO.Stream
  • ??-????? ?????? ?? ????? Stream
  • Flush() ??????? ??????? ?? ?????????? ??????
    ??? ????????? ?? ??????????/?????? ?? ?????
  • Close() ??????? Flush(), ??????? ???????? ???
    ????????? ?? ??????????/?????? ?? ????? ?
    ??????????? ???????????? ???????
  • Seek(offset, SeekOrigin) ????????? ????????
    ??????? ? ?????? (??? ?? ????????) ? ??????
    ?????????? ?????? ????????, ???? ??? ????????
    ??????? ? ??????
  • SetLength(long) ??????? ????????? ?? ??????
    (??? ?? ????????)
  • ??? ????????????? ?? ?? ????????, ?? ??????
    ?????????? NotSupportedException

16
?????????? ??????
  • ???????????? ??????
  • ????????? ??????? ? ???? ?????????? ??????????
    ??????????????????
  • ??? ?????? ?? ????????? ?? 1 ???? ?? ???????? ???
    ??????? ????????? ?????? ? ?? ???????? ???
    ???????? ?????
  • ??? ???????? ?????? ?? ?????? ????? ?? ??????
    (????? ? ????? ????? ????????)
  • ??? ?????? ??????? ?? ???????? ??? ???????? ?????
    (????? ????? ????? ?????)
  • ??? ?????????? ?? ?????? ??? ??? ????????? ??
    Flush() ??????? ?? ?????? ?? ???????? ???
    ????????? ?? ??????????/??????
  • ? .NET Framework ?? ???????? ?????
    System.IO.BufferedStream

17
??????? ??????
  • ?? ?????? ? ??????? ?????? ?? ???????? ??????
    FileStream
  • ?????? FileStream
  • ????????? ????? Stream ? ???????? ?????? ??????
    ?????? ? ????????
  • ???????? ??????, ??????, ????????????? (???
    ????????????, ?????? ?? ?????? ????? ????????
    ???? ????????)
  • ? ???????????? ?? ?? ??????
  • ??? ?? ????
  • ????? ?? ???????? ?? ?????
  • ????? ?? ??????
  • ?????? ?? ??????????? ???????????

18
??????? ??????
  • ???????????? ?? ?????? ?????
  • FileMode ????? ?? ???????? ?? ?????
  • Open, Append, Create, CreateNew, OpenOrCreate,
    Truncate
  • FileAccess ????? ?? ???????? ?? ?????
  • Read, Write, ReadWrite
  • FileShare ????? ?? ?????? ?? ????? ???????????
    ?????? ??? ?????? ??????? ?????
  • None, Read, Write, ReadWrite

FileStream fs new FileStream(string fileName,
FileMode , FileAccess , FileShare)
19
??????? ?????? ??????
// ?????? ?? ?????? ???? (0x00) ? ??????? ???? ?
255 (0xFF) FileStream fs new FileStream("input.b
in", FileMode.Open, FileAccess.ReadWrite,
FileShare.None) using (fs) byte buf
new byte16384 while (true)
int bytesRead fs.Read(buf, 0, buf.Length)
if (bytesRead 0) break
for (int i0 iltbytesRead i)
if (bufi 0) bufi
255 fs.Seek(-bytesRead,
SeekOrigin.Current) fs.Write(buf, 0,
bytesRead)
20
???????????? 2
  • ?????? ?? ???????? ? ??????? ????

21
??????? ?????? ??????
using System using System.IO // ???????? ????
?? ???????? ??????? ? ??????? ???? class
CountZeros static void Main(string args)
long countOfZeros 0
FileStream fs new
FileStream("input.bin", FileMode.Open,
FileAccess.Read, FileShare.Read)
try byte buf new
byte4096 while (true)
int bytesRead
fs.Read(buf, 0 , buf.Length)
if (bytesRead 0)
break (???????? ??????????)
22
??????? ?????? ??????
for (int i0 iltbytesRead i)
if (bufi
0) countOfZeros

finally fs.Close()
Console.WriteLine( "The
count of zeros in the file is 0.",
countOfZeros)
23
???????? ????????!
  • ???? ???????? ??? ?? ???????? ?? ??????? ?
    ???????
  • ????? ????? ??? Read() ?? ??????? ?????
    buf.Length ?????, ? ??-??????

using ( FileStream inFile new FileStream(
"input.bin", FileMode.Open), outFile
new FileStream( "output.bin",
FileMode.Create)) byte buf new
byte4096 while (true) if
(inFile.Read(buf, 0, buf.Length) 0)
break outFile.Write(buf, 0,
buf.Length)
24
????? ? ??????
  • ??????? ? ???????? ?? ???????, ?????
  • ????????? ???????? ? ??????
  • ?????????? ?????? ? ?????? ?? ???????? ?????????
    ?? ?????, ???????? ???????????? ??????, ????????
    ?????????? ? ????? ??????
  • ????? ??????? ? ????????
  • ????????? BinaryReader ? BinaryWriter
  • ?????????? ?????? ? ????????? ?? ????????????
    ?????? ????? ? ??????? ???
  • ReadChar(), ReadChars(), ReadInt32(),
    ReadDouble(),
  • Write(char), Write(char ), Write(Int32),
    Write(Double),
  • ?????????? ?????? ? ?????? ?? string, ???? ??
    ???????? ???? ????? ?? ???????, ?????????? ??
    ????????? ?? ReadString(), Write(string)

25
??????? ????? ? ?????? ??????
  • ????? ??????? ???? ??? ?????? ??? ?????? (???
    string, ??????? int)
  • ?? ???????? ? ?????? ?? ?????? ????? ?? ????????
    ??????? ???

static void AppendPerson(BinaryWriter aWriter,
string aName, int aAge)
aWriter.Write(aName) aWriter.Write(aAge)
static void ReadPerson(BinaryReader aReader,
out string aName, out int aAge) aName
aReader.ReadString() aAge
aReader.ReadInt32()
26
??????? ????? ? ?????? ??????
  • ??? ? ???????? ?????? ?? ????????? ? ????????? ??
    ??????? ??????

static void Main(string args) //
????????? ????? data.bin ? ????????? // ?
???? ??????? ?????? FileStream fs
new FileStream("data.bin", FileMode.Create)
using (fs) using (BinaryWriter
writer new BinaryWriter(fs))
AppendPerson(writer, "??? ????", 57)
AppendPerson(writer, "??? ????", 48)
AppendPerson(writer, "???? ????", 26)
(???????? ??????????)
27
??????? ????? ? ?????? ??????
  • ??? ? ???????? ?????? ?? ????????? ? ????????? ??
    ??????? ??????

// ????????? ? ??????????? ?????? ?????? ??
????? data.bin fs new FileStream("data.bin",
FileMode.Open) using (fs)
using (BinaryReader reader new
BinaryReader(fs)) while
(fs.Position lt fs.Length-1)
string name int age
ReadPerson(reader, out name, out
age) Console.WriteLine("0 -
1", name, age)
28
???????????? 3
  • ??????? ??????? ??? ??????

29
???????? ????? ? ??????
  • ????????? TextReader ? TextWriter
  • ?????????? ?????? ? ????????? ?? ????????
    ?????????? (??????, ????????? ? ??? ???)
  • ????????? ?? ?? ????? ????? ???? ????? Console
    (??? ReadLine(), WriteLine(), )
  • ???????? ?? ??? ??? ? ???????? ?? ??????????
    ?????????
  • LF (0x0A) ? Unix ? Linux
  • CR LF (0x0D 0x0A) ? Windows ? DOS
  • ReadLine() ??????? ??????? ???
  • ReadToEnd() ??????? ?????? ?? ???? ?? ??????
  • Write() ???? ????? ? ??????
  • WriteLine() ???? ??????? ??? ? ??????

30
???????? ????? ? ??????
  • ????????? TextReader ? TextWriter ?? ?????????? ?
    ?? ?? ????????? ????????
  • ????????? ?? ???????? ???????
  • StreamReader ???? ???????? ????? ?? ?????
  • StringReader ???? ???????? ????? ?? ???
  • StreamWriter ???? ???????? ????? ? ?????
  • StringWriter ???? ???????? ????? ? ???,
    ???????? ???????? StringBuilder
  • ??????
  • ????? ? ??????? ????. ?????? ?? ??????? ?????????
    ? ???????? ?? ????? ??? ?? ?????
  • ?????????? StreamReader ? StreamWriter, ?????
    ????? ??? ? ?? ??????????? ???? ???????? ?????????

31
???????? ????? ? ?????? ??????
// ?????????? ?? ???????? ?? ??????? ???? static
void Main(string args) StreamReader
reader new StreamReader("in.txt") using
(reader) StreamWriter writer new
StreamWriter("out.txt") using (writer)
int lineNumber 0
string line reader.ReadLine()
while (line ! null)
lineNumber writer.WriteLine("
0,5 1", lineNumber,
line) line reader.ReadLine()

32
???????????? 4
  • ?????????? ?? ???????? ?? ??????? ????

33
???????? ????? ? ?????? ??????
// Find-text-in-file Search Utility static void
Main(string args) if (args.Length lt 2)
Console.WriteLine("Use FindInFile
file text") return string
fileName args0 if (!File.Exists(fileName)
) Console.WriteLine(
"Could not find file " fileName)
return string textToFind
args1.Trim() (???????? ??????????)
34
???????? ????? ? ?????? ??????
using (StreamReader reader
File.OpenText(fileName)) bool found
false int lineNumber 0
string line while ((line
reader.ReadLine()) ! null)
lineNumber if (line.IndexOf(textToF
ind) gt -1)
Console.WriteLine("00000 1",
lineNumber, line) found
true if
(!found) Console.WriteLine("
Text not found!")
35
???????????? 5
  • ??????? ?? ??? ? ??????? ????

36
?????, ?????? ? ?????????
  • ??????? ? ???????? ????????? ????????? ?? ??
    ??????? ? ???????? ??????????
  • ?? ???????????? ?? ???????? ???????? UTF-8
  • ? ?????????????? ????? ?? ?? ??????? ? ?????
    ?????????, ????????? ?? System.Encoding
  • ????????? ?? windows-1251 ?????
  • ????????? ?? windows-1251 ?????

Encoding win1251 Encoding.GetEncoding("windows-1
251") StreamReader reader new
StreamReader("in.txt", win1251)
Encoding win1251 Encoding.GetEncoding("windows-1
251") StreamWriter writer new
StreamWriter("out.txt", win1251)
37
????????? File ? FileInfo
  • File ? FileInfo ?? ??????? ???????, ?????
    ??????????? ?????????????? ??
  • ????????? ?? ???? Create(), CreateText()
  • ???????? ?? ???? Open(), OpenRead(),
    OpenWrite(), AppendText()
  • ???????? ?? ???? CopyTo()
  • ??????? (????????????) ?? ???? MoveTo()
  • ????????? ?? ???? Delete()
  • ????????? ?? ??????? ?? ???????? ?????? ? ???????
    LastAccessTime ? LastWriteTime
  • ???????? ?? ???????????? Exists()
  • ?????? File ?????????? ???? ?????? ????????, ?
    FileInfo ???? ?????????

38
File ? FileInfo ??????
static void Main(string args)
StreamWriter writer File.CreateText("test1.txt")
using (writer)
writer.WriteLine("????? ?? ????!")
FileInfo fileInfo new FileInfo("test1.txt")
fileInfo.CopyTo("test2.txt", true)
fileInfo.CopyTo("test3.txt", true) if
(File.Exists("test4.txt"))
File.Delete("test4.txt")
File.Move("test3.txt", "test4.txt")
39
Directory ? DirectoryInfo
  • Directory ? DirectoryInfo ?? ???????, ?????
    ??????????? ?????????????? ??
  • ????????? ?? ?????????? ? ?????????????
    Create(), CreateSubdirectory()
  • ????????? ?? ?????? ??????? GetFiles()
  • ????????? ?? ?????? ?????????????
    GetDirectories()
  • ??????? (????????????) MoveTo()
  • ????????? Delete()
  • ????????? ?? ??????? ?????????? Parent
  • ???????? ?? ???????????? Exists()
  • ????????? ?? ??????? ??? FullName
  • ?????? Directory ?????????? ???? ?????? ????????,
    ? DirectoryInfo ???? ?????????

40
?????? Directory ??????
class DirectoryTraversal private static
void Traverse(string aPath)
Console.WriteLine("0", aPath)
string subdirs Directory.GetDirectories(aPath)
foreach (string subdir in subdirs)
Traverse(subdir)
string files Directory.GetFiles(aPath)
foreach (string f in files)
Console.WriteLine(f)
static void Main(string args)
string winDir Environment.SystemDirectory
Traverse(winDir)
41
???????????? 6
  • ????????? ?? ??????????

42
?????? Path
  • ?????? System.IO.Path ?????????? ??????????????
    ?? ?????? ? ??????
  • ??-????? ???????? ? ??????
  • DirectorySeparatorChar ????????, ????? ??????
    ???????????? ? ???? ("\" ?? Windows ? "/" ?? Unix
    ? Linux ??????? ???????)
  • Combine() ????????? ????? ??? ? ????????? ???
  • GetExtension() ??????? ???????????? ?? ?????
    ???? (??? ???)
  • GetFileName() ??????? ????? ?? ????? ?? ?????
    ????? ??? (??? ???)
  • GetTempFileName() ??????? ???????? ???? ?
    ???????? ??? ? ?????? ??????? ? ????? ????? ??

43
???????? ??????? ??????
using System using System.IO class
TempFilesDemo static void Main(string
args) String tempFileName
Path.GetTempFileName() try
using (TextWriter writer
new StreamWriter(tempFileName))
writer.WriteLine("This is just a
test")
File.Copy(tempFileName, "test.txt")
finally
File.Delete(tempFileName)
44
????????? ??????????
  • ??????????? ?????????? ?? ???????? ??
    System.Environment.GetFolderPath(
    Environment.SpecialFolder)
  • SpecialFolder.DesktopDirectory ????? ????????
    ???? ?? ??????? ??????????
  • SpecialFolder.ApplicationData ????? ??????????
    ?? ???????????? ?? ??????? user
  • SpecialFolder.Favorites ???????????? "My
    Documents" ?? ??????? ??????????
  • SpecialFolder.Favorites ???????????? ? ????????
    ?????? ?? ??????? ??????????
  • SpecialFolder.MyPictures/MyMusic ??????????
    "????? ????????/??????" ?? ??????? ??????????

45
????????? ?????????? ??????
string myDocuments Environment.GetFolderPath(
Environment.SpecialFolder.Personal) Console.Wri
teLine(myDocuments) // C\Documents and
Settings\Administrator\My Documents string
myDesktop Environment.GetFolderPath(
Environment.SpecialFolder.DesktopDirectory) Conso
le.WriteLine(myDesktop) // C\Documents and
Settings\Administrator\Desktop string
myFavourites Environment.GetFolderPath(
Environment.SpecialFolder.Favorites) Console.Writ
eLine(myFavourites) // C\Documents and
Settings\Administrator\Favorites string myMusic
Environment.GetFolderPath(
Environment.SpecialFolder.MyMusic) Console.WriteL
ine(myMusic) // C\Documents and
Settings\Administrator\My Documents\My Music
46
?????? FileSystemWatcher
  • ?????? FileSystemWatcher ????????? ?????????? ??
    ????????? ??????? ?? ???????? ??????? ????
  • ?????????, ???????, ???????????? ? ????????? ??
    ???? ??? ??????????
  • ??-????? ???????? ? ???????
  • Path ????????????, ????? ?? ?????????
  • Filter ?????? ?? ????????????? ???????,
    ???????? "." ??? ".exe"
  • NotifyFilter ?????? ?? ????????????? ???????,
    ???????? FileName, LastWrite, Size
  • Created, Changed, Renamed, Deleted ???????,
    ????? ?? ???????? ??? ???????. ???????? ????????
    ?? ?? ????? ?????!

47
FileSystemWatcher ??????
static void Main() string currentDir
Environment.CurrentDirectory
FileSystemWatcher w new
FileSystemWatcher(currentDir) w.Filter
"." w.NotifyFilter NotifyFilters.FileName
NotifyFilters.DirectoryName
NotifyFilters.LastWrite w.Created new
FileSystemEventHandler(OnCreated) w.Changed
new FileSystemEventHandler(OnChanged)
w.Renamed new RenamedEventHandler(OnRenamed)
w.EnableRaisingEvents true
Console.WriteLine("0 is being watched now...",
currentDir) Console.WriteLine("Press
Enter to exit.") Console.ReadLine()
(???????? ??????????)
48
FileSystemWatcher ??????
private static void OnCreated(object aSource,
FileSystemEventArgs aArgs)
Console.WriteLine("File 0 created - 1",
aArgs.Name, aArgs.ChangeType) private
static void OnChanged(object aSource,
FileSystemEventArgs aArgs)
Console.WriteLine("File 0 changed - 1",
aArgs.Name, aArgs.ChangeType) private
static void OnRenamed(object aSource,
RenamedEventArgs aArgs) Console.WriteLine("F
ile 0 renamed to 1", aArgs.OldName,
aArgs.Name)
49
???????????? 7
  • ?????????? ?? ????????? ??? ????????? ???????

50
?????? ? IsolatedStorage
  • ???????????? IsolatedStorage
  • ?? ???????? ?????? ??????????, ????? ???? ?????
    ?? ?????? ?? ???????? ????? ????, ?????? ??
    ????????? ?????? ???????
  • ???????? ??? ??????????, ?????????? ??
    Web-???????? ? ????????
  • IsolatedStorage ?????????? ????????? ?????????
    ??????? ???????
  • ?????????? ?? ????
  • ??? ?? ????????? ?? ???????????? ?????? ??
    ?????????? ??????? ?? ??????? ????
  • ????????? ?? ?????? ?? ????????? ??????? ???????
    ?e ??????? ? ?????? System.IO.IsolatedStorage
    (??. MSDN).

51
???? ? ????? ?.NET Framework
????????
52
??????????
  1. ????? ????????????? ???????? ? .NET Framework?
    ??? ?? ????????? ???????? ? ???? ??? ?? ?????????
    ??????? ?? ?????? ? ???????
  2. ???????? ????????, ????? ?????? ??????? ???????
    ?? ???????? ??????? ????? (???????? ???).
    ??????????? ??????? ????????? ?? ????????
    ????????? ?????? ???? ?? ????? ? ??????????
    "?????????? ???" ? ?????? ???? ?? ?????????
    ?????. ??????? ???? ?? ????? ????????? ? ??????
    ???? ?? ????????? ????? ? ?.?. ??? ????????? ??
    ????????? ???? ???????????? ??? ??????.
    ??????????? ??????? ??????.
  3. ???????? ????????, ????? ???????? ?????????,
    ???????? ? ??????????? ????????. ????????????
    ??????? ?????? ?? ?? ??????? ? ??????????????.

53
??????????
  1. ???????? ????????, ????? ?????? ????????? ???????
    ???? ?? ??????? ????? ??????? ?? ???? ?????
    ????????, ??????? ????? ???????????? ? ?.?.
    ??????????? ??????? ?????? ??? ?? ??????????
    ???????? ???????. ?????????? ?? ?? ??????????????
    ????????? ?? ? ????????? ?? ?????? ??? ??????? ?
    ?????? 700 MB?
  2. ???????? ????????, ????? ??????? ????? ???????
    ???? ?? ??????? ????? (??????? ? ???????? ??????,
    ???????? 1.44 MB). ????????? ?????? ?? ??
    ????????? ???????????.
  3. ???????? ????????, ????? ????????? ???????,
    ?????????? ?? ??????????? ???????? ? ????????????
    ??????????? ????, ?? ????? ?? ????????.

54
??????????
  1. ???????? ????????, ????? ?? ????? ?????? ??
    ?????????? ??????? ?????? ? ??????? ???? ?????
    ??????? ?? ??????? ?? ??????? ??? ????????? (???
    ????? ???? ?????). ???????? ?? ?????????? ???????
    ?????? ?? ?? ??????? ?? ??????? ???? words.txt.
    ??????????? ???????? ??????? ???? ? ???? ????
    ???????? ????????? ? ????, ???????? ??????? ????
    ? ????????????? ????????? ???? ? ????? ??
    ???????? ???? ?????? ????.
  2. ???????? ????????, ????? ????? ????? ???????? ???
    ??? ?????? ???????? ??????? (.txt) ?? ??????
    ?????????? ? ??????? ?????????????. ??? ?????
    ?????????? ?????? ?? ?? ????????? ??????? ??? ??
    ?????, ?????? ? ???????? ????????????, ??????? ??
    ???? ? ???? ???? ? ???????????? ?? ???? ???.

55
??????????
  1. ???????? ????????, ????? ?????? ?????? ????????
    ??????? (.txt) ?? ??????? ???? ???? ????????
    ????????? ? ?????? ???? ?????? ?? ??????? ?????
    1. ?????? ? ???????? ????????? ??????????. 2.
    ?????? ???????? ?? ?????? ?????? ??????? ?? ???
    ??????????, ?????? ? ????????? ?????? ??????? ?
    ??? ? ?????? ? ???????? ???????? ? ?????????????.
  2. ???????? ????????, ????? ????????? ????? ??
    ???????? ??? ???? ??? ??????. ?? ????? ???????
    ?????? ?? ?? ????????? ???????? ???, ??????????
    ?????, ???? ? ?????? ?????. ???????????? ??????
    ?? ???????? ?? ???????, ?? ??????? ?? ??????? ??
    ??? ? ?? ?????????? ?????, ?? ????????? ??
    ?????????? ?? ????? ? ?? ??????????? ?? ??????
    ???????? ?? ?????. ??????????? ??????? ????? ?
    ??????.

56
??????????
  1. ???????? ????????, ????? ????? ????? ??????? ????
    ?? ?????? ?????????? ? ??? ??????? ??
    ???????????? ?? ?? ????????? ?? ?????????.
  2. ???????? ????????, ????? ??? ????? ??????????
    ???? ??????????? ?? ????? ?? ? ?? ??????? ?
    ??????? ???? ? IsolatedStorage ????????. ???
    ???????? ?????????? ?????????? ?????? ?? ??
    ?????????? ? ?????, ????????? ?? IsolatedStorage
    ???????? ? ?? ?? ???? ?????????? ?? ?? ???????.

57
?????????? ??????????
  • MSDN Library http//msdn.microsoft.com
  • ????? ????????, ?????? ? ???????
    http//www.nakov.com/dotnet/2003/lectures/Streams-
    and-Files.doc
  • ?????? ??????, ?????? ? ???????
    http//www.nakov.com/2003/dotnet/lectures/Streams-
    and-Files.doc
  • MSDN Training, Programming with the Microsoft
    .NET Framework (MOC 2349B), Module 10 Data
    Streams and Files
  • ??????? ?????, ???????? ???????????? ? Java,
    ?????, 2004, ISBN 954-775-305-3, ???? 1.2
    (????/????? ? Java)

58
?????????? ??????????
  • MSDN Library Working with I/O (.NET Framework
    Developer's Guide) http//msdn.microsoft.com/
    library/en-us/cpguide/html/cpconworkingwithio.asp
Write a Comment
User Comments (0)
About PowerShow.com