here's a better way =)
// 12345 12345
// will output "abc | def"
Console.WriteLine("{0,-5}|{1,5}", "abc", "def");
// this will also produce the same results, but stored in
// a string so you can output it to a text filee
string str = string.Format("{0,-5}|{1,5}", "abc", "def");
Console.ReadLine();
in the format string "{0,-5}", the -5 says "pad to a width of 5 spaces,
and put the data on the left"
the "{0,5}" says "pad to a width of 5 spaces, and put the data on the
right"
this isn't going to work if you have data that is 6 or more characters
long, it'll just write the whole word out, but you could always to a
"longdata".Substring(0, 5) to grab the first 5 characters
sound good?
John Timney (MVP) wrote:
Thats just looks to be tab delimited data. Try adding vbTab or \t if its
c# to your text string and see if thats what your after.
outputString = "This is text" & vbTab & "and text after tab"
outputString = "This is text text\tand text after tab";
--
Regards
John Timney (MVP)
"Tom" <To*@gmail.com> wrote in message
news:ep**************@TK2MSFTNGP04.phx.gbl... each line can be different in length. I get text files now that are fixed
how are they created?
example:
line 1
20060601 BMW 1999 Smith 45,500
20050601 BMW 2003 Jones 75,200
20060102 Lexus 2006 Smith 25,365
and I have to read this files and get all the data, so now I need to
create a file in this format so I can send out and have a vendor read it.
there has to b a way in doing this
"John Timney (MVP)" <x_****@timney.eclipse.co.uk> wrote in message
news:Q6********************@eclipse.net.uk... If you assume every line was 80 chars in length and append a carriage
return at the end of every line you have something to measure and pad
spaces against. This will give you fixed positioning within the file,
but you'll need to force font to something like courier to see this
aligned when you view it which I dont think you can do in the text file
itself. For that you'll need to use RTF, PDF or something else for that.
--
Regards
John Timney (MVP)
"John" <me@me.com> wrote in message
news:%2****************@TK2MSFTNGP05.phx.gbl...
I can create text file, but how can I create a text file where the values
are at the same location on every line?
I want to define the location where the values starts and define the
length of the value.