I read a file from the file system and FTP it to an FTP server. I now have a request to skip the first line (it’s a CSV with header info). I think I can somehow do this with the Offset of the stream.Read method (or the write method) but I am not sure how to translate the byte array offset from a single line.
How would I calculate the offset to tell it to only read from the 2nd line of the file?
Thanks
// Read the file to be uploaded into a byte array
stream = File.OpenRead(currentQueuePathAndFileName);
var buffer = new byte[stream.Length];
stream.Read(buffer, 0, buffer.Length);
stream.Close();
// Get the stream for the request and write the byte array to it
var reqStream = request.GetRequestStream();
reqStream.Write(buffer, 0, buffer.Length);
reqStream.Close();
return request;
You should use File.ReadAllLines. It returns array of strings. Then just
strArray.Skip(1)will return you all lines except of first.UPDATE
Here is the code: