×
INTELLIGENT WORK FORUMS
FOR COMPUTER PROFESSIONALS

Contact US

Log In

Come Join Us!

Are you a
Computer / IT professional?
Join Tek-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!

*Tek-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Students Click Here

Does StreamWriter drop leading tabs?

Does StreamWriter drop leading tabs?

Does StreamWriter drop leading tabs?

(OP)
Colleagues,
Here's what's happening: I, the Program, read a "truncated" XML file which I need to format and write back N times.
Formatting code:

CODE --> .NET

' Add 4 Tab chars in front of every line 1st:
lsBlock = lsBlock.Replace(vbCrLf, vbCrLf & Replicate(Chr(9), 4))

' The starting tag <CheckDetail> - move it 1 tab to the right
lsBlock = lsBlock.Replace(Replicate(Chr(9), 4) & "<CheckDetail>", Replicate(Chr(9), 3) & "<CheckDetail>")
' The ending tag </CheckDetail> - move it 1 tab to the left:
lsBlock = lsBlock.Replace(Replicate(Chr(9), 4) & "</CheckDetail>", Replicate(Chr(9), 3) & "</CheckDetail>")

Dim loStreamWriter As New StreamWriter(tcFileOut, True)

'Add compound section's starting tag
loStreamWriter.Write(Replicate(Chr(9), 2) & "<CheckDetails>" & vbCrLf) 
Then the For-Next cycle to write the whole block these N times - nothing interesting, so I skip it here, and I stop at the moment after the Stream is filled out.
So far, so good: note that, at the break point, the lcBlock in the Locals does have these leading Tabs.


But when I open the output file...

This bloody <CheckDetail> tag is written w/o those leading Tabs!

Hence the question in subject.
OR
Do I do something wrong?
Please advise.

TIA!

Regards,

Ilya

RE: Does StreamWriter drop leading tabs?

Before we proceed ... i'm assuming that Replicate is essentially an alias for strdup

The only way I can almost replicate your problem is if the first character(s) in lsBlock at this point in your code

' Add 4 Tab chars in front of every line 1st:
lsBlock = lsBlock.Replace(vbCrLf, vbCrLf & Replicate(Chr(9), 4))

are not vbCrLf

RE: Does StreamWriter drop leading tabs?

(OP)
Bleen! (T's in Russian soapbox , you don't wanna kno...)
How stupid this old senile fool me could be! blush
The opening tag <CheckDetail> starts from pos. 1, and of course the line

CODE

lsBlock = lsBlock.Replace(Replicate(Chr(9), 4) & "<CheckDetail>", Replicate(Chr(9), 3) & "<CheckDetail>") 

does nothing!

Thank you, colleague! thanks2 U R Z Man! bow

Problem resolved, case is being closed.

Regards,

Ilya

RE: Does StreamWriter drop leading tabs?

Блеен - I know it as a very tasty 'pancake' wavey


---- Andy

There is a great need for a sarcasm font.

RE: Does StreamWriter drop leading tabs?

(OP)
Actually, "pancake" in Russian is "блин" (I write "bleen" in order for Anglophones to pronounce it properly), but it's also euphemism for the Russian cursing word as expression of utmost disappointment.
Just FYI.

Regards,

Ilya

Red Flag This Post

Please let us know here why this post is inappropriate. Reasons such as off-topic, duplicates, flames, illegal, vulgar, or students posting their homework.

Red Flag Submitted

Thank you for helping keep Tek-Tips Forums free from inappropriate posts.
The Tek-Tips staff will check this out and take appropriate action.

Reply To This Thread

Posting in the Tek-Tips forums is a member-only feature.

Click Here to join Tek-Tips and talk with other members! Already a Member? Login

Close Box

Join Tek-Tips® Today!

Join your peers on the Internet's largest technical computer professional community.
It's easy to join and it's free.

Here's Why Members Love Tek-Tips Forums:

Register now while it's still free!

Already a member? Close this window and log in.

Join Us             Close