#6 04.07.07 19:26
Re: [С#] получение данных из файла.
O'Reilly. Программирование на C# написал(а):
Работа с файлами
Объект DirectoryInfo может, кроме всего прочего, возвратить коллек-
цию всех файлов в каждом найденном подкаталоге. Метод GetFiles()
возвращает массив объектов FileInfo, каждый из которых описывает
файл. Объекты FileInfo и File связаны друг с другом аналогично тому,
как связаны DirectoryInfo и Directory. Как и методы класса Directory,
все методы класса File - статические; подобно методам класса DirectoryInfo,
все методы класса FileInfo являются нестатическими.
Offline
#7 04.07.07 19:36
Re: [С#] получение данных из файла.
A Programmer's Introduction to C# by Eric Gunnerson, Apress написал(а):
Reading and Writing Files
There are two ways to get streams that connect to files. The first is to use the FileStream class, which provides full control over file access, including access mode, sharing, and buffering.Код: C#:
using System; using System.IO; class Test { public static void Main() { FileStream f = new FileStream("output.txt", FileMode.Create); StreamWriter s = new StreamWriter(f); s.WriteLine("{0} {1}", "test", 55); s.Close(); f.Close(); } }It is also possible to use the functions in the File class to get a stream to a file. This is most useful if there is already a File object with the file information available, as in the PrintFile() function in the next example.
Offline

