开发者

Cygwin Commands from Web Service ASP.NET C#

开发者 https://www.devze.com 2023-03-21 06:41 出处:网络
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 st

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#

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号