1

I want to execute a cygwin command from within a webservice.

Basically I want to use the "tail" command to strip off the first line of a file in C#.

Cœur
  • 37,241
  • 25
  • 195
  • 267
user843453
  • 241
  • 2
  • 6

4 Answers4

1

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#.

Florian Mayer
  • 3,041
  • 24
  • 17
  • Do you have nay idea how to do that. My file is large more than 40k rows and to copy it into another file will take up time. – user843453 Jul 17 '11 at 02:58
  • Exactly - plus: **if** you want to call an exe from your web service, I certainly wouldn't use another emulation layer like Cygwin.... try and find a native Windows `tail.exe` (see: http://tailforwin32.sourceforge.net/) – marc_s Jul 17 '11 at 08:33
1

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.

Community
  • 1
  • 1
tbddeveloper
  • 2,407
  • 1
  • 23
  • 39
0

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.

tbddeveloper
  • 2,407
  • 1
  • 23
  • 39
  • NO . I want to strip of the first line. It's a CSV file so I need to strip the first line since the columns names are in the second line. The files are huge so I am using MS Text Driver to read it instead of using stream reader. Please suggest – user843453 Jul 17 '11 at 02:57
0

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#

Community
  • 1
  • 1
Michael Dillon
  • 31,973
  • 6
  • 70
  • 106