Показать сообщение отдельно
Старый 11.01.2012, 14:11   #1  
Blog bot is offline
Blog bot
Участник
 
25,643 / 848 (80) +++++++
Регистрация: 28.10.2006
palleagermark: Sample file import with StreamReader
Источник: http://palleagermark.blogspot.com/20...eamreader.html
==============

Here is one example of how you can import files with .NET's StreamReader:
X++:
static void ImportWithStreamReader(Args _args)
{
    Filename                filename = @'C:\Temp\importme.txt';           
    System.IO.StreamReader  reader;
    System.String           line;
    InteropPermission       interopPermission;
   
    interopPermission = new InteropPermission(InteropKind::ClrInterop);
    interopPermission.assert();

    reader = new System.IO.StreamReader(filename, 

                                       System.Text.Encoding::get_UTF8());

    line = reader.ReadLine();

    while (!System.String::IsNullOrEmpty(line))
    {
        // Do something with line

        line = reader.ReadLine();
    }

    reader.Close();
    reader.Dispose();
}
If you can work with the file as on big chunk of text you can get away with just reading once, using the ReadToEnd method.

Read more about StreamReader on MSDN.


Источник: http://palleagermark.blogspot.com/20...eamreader.html
__________________
Расскажите о новых и интересных блогах по Microsoft Dynamics, напишите личное сообщение администратору.

Последний раз редактировалось Poleax; 11.01.2012 в 17:14.