I want to execute a cygwin command from within a webservice.
Basically I want to use the "tail" command to strip off t开发者_运维百科he first line of a file in C#.
Calling another program just to strip the first line of a file sounds like a very bad idea. You might want to try and just strip the first line in C#.
I've not personally dealt with huge text files before, so I did a bit of searching around;
Efficient way to delete a line from a text file
Basically, this one gives an answer you don't like, but if .NET 4 is an option memory-mapped files might help you out.
Are you looking to remove it or read it? If you want the first line of the file, you can just open the file stream (File.Open) and take the first line.
Normally Cygwin is installed in C:\CYGWIN so you should be able to run tail (from /usr/bin) by calling "C:\cygwin\usr\bin\tail.exe" from your code.
That said, you really should not be doing this at all. Just use a StreamReader properly. This question has a nice example to show how: Reading large text files with streams in C#
精彩评论