Sample file import with StreamReader
Views (6360)
Here is one example of how you can import files with .NET's StreamReader:
Read more about StreamReader on MSDN.
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());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.
line = reader.ReadLine();
while (!System.String::IsNullOrEmpty(line))
{
// Do something with line
line = reader.ReadLine();
}
reader.Close();
reader.Dispose();
}
Read more about StreamReader on MSDN.

Like
Report
*This post is locked for comments