How to write to file " "

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Mrozu

    #1

    How to write to file " "

    Hi
    When I try write to file(with StreamWriter) some string, i have some
    problem. I can't write text with "". For example i want to wrote
    "Hello" . When i make

    Dim sw As New System.IO.Strea mWriter("C:\tex t.txt")

    sw.write("Hello ")

    ..
    ..
    ..
    ..

    In my file is Hello, instead of "Hello". How i can write " ??

    thx Mrozu

  • The Grim Reaper

    #2
    Re: How to write to file " "

    The quotation mark is represented by a character - ASCII number 34.
    You can create a character by using Convert.ToChar( 34), like so;

    Dim sw As New System.IO.Strea mWriter("C:\Tex tFile.txt")

    sw.Write(Conver t.ToChar(34) & "Hello" & Convert.ToChar( 34))


    I'm sure the experts in this group can suggest better methods...

    _______________ _______________ ________
    The Grim Reaper

    "Mrozu" <gmrozu@yahoo.p l> wrote in message
    news:1129988178 .886551.18910@o 13g2000cwo.goog legroups.com...[color=blue]
    > Hi
    > When I try write to file(with StreamWriter) some string, i have some
    > problem. I can't write text with "". For example i want to wrote
    > "Hello" . When i make
    >
    > Dim sw As New System.IO.Strea mWriter("C:\tex t.txt")
    >
    > sw.write("Hello ")
    >
    > .
    > .
    > .
    > .
    >
    > In my file is Hello, instead of "Hello". How i can write " ??
    >
    > thx Mrozu
    >[/color]


    Comment

    • Herfried K. Wagner [MVP]

      #3
      Re: How to write to file &quot; &quot;

      "Mrozu" <gmrozu@yahoo.p l> schrieb:[color=blue]
      > When I try write to file(with StreamWriter) some string, i have some
      > problem. I can't write text with "". For example i want to wrote
      > "Hello" . When i make
      >
      > Dim sw As New System.IO.Strea mWriter("C:\tex t.txt")
      >
      > sw.write("Hello ")
      >
      > In my file is Hello, instead of "Hello". How i can write " ??[/color]

      'sw.Write("""He llo""")'.

      --
      M S Herfried K. Wagner
      M V P <URL:http://dotnet.mvps.org/>
      V B <URL:http://classicvb.org/petition/>

      Comment

      • Mrozu

        #4
        Re: How to write to file &quot; &quot;

        Thanks Grim Reaper. It works :)

        Thx Mrozu

        Comment

        • webmaster@visionforceweb.com

          #5
          Re: How to write to file &quot; &quot;

          You could also do this:

          Write("""My text""")


          If you put two quotation marks in the place of one inside the text, that does the trick.

          *************** *************** *************** *************** **********
          Sent via Fuzzy Software @ http://www.fuzzysoftware.com/
          Comprehensive, categorised, searchable collection of links to ASP & ASP.NET resources...

          Comment

          • The Grim Reaper

            #6
            Re: How to write to file &quot; &quot;

            Personal preference - to me that makes code very unreadable!

            Especially with ASP scripts.

            _______________ _______________ ____
            The Grim Reaper

            "Alex C. Barberi" <webmaster@visi onforceweb.com> wrote in message
            news:ex$DUHy1FH A.2008@TK2MSFTN GP10.phx.gbl...[color=blue]
            > You could also do this:
            >
            > Write("""My text""")
            >
            >
            > If you put two quotation marks in the place of one inside the text, that
            > does the trick.
            >
            > *************** *************** *************** *************** **********
            > Sent via Fuzzy Software @ http://www.fuzzysoftware.com/
            > Comprehensive, categorised, searchable collection of links to ASP &
            > ASP.NET resources...[/color]


            Comment

            • Mrozu

              #7
              Re: How to write to file &quot; &quot;

              Thx everyone. all mehods work. But why """(3x"). i were trying
              """"HELLO"" "" but it doesn't work. I can't understand why 3:) But ok,
              it works, and it is the most important:)

              Thx Mrozu

              Comment

              • Herfried K. Wagner [MVP]

                #8
                Re: How to write to file &quot; &quot;

                "Mrozu" <gmrozu@yahoo.p l> schrieb:[color=blue]
                > Thx everyone. all mehods work. But why """(3x"). i were trying
                > """"HELLO"" "" but it doesn't work. I can't understand why 3:) But ok,
                > it works, and it is the most important:)[/color]


                The two outer quotation marks are used to delimit the string literal. Each
                quotation mark inside the string literal is encoded by two consecutive quote
                characters.

                --
                M S Herfried K. Wagner
                M V P <URL:http://dotnet.mvps.org/>
                V B <URL:http://classicvb.org/petition/>

                Comment

                • Mrozu

                  #9
                  Re: How to write to file &quot; &quot;

                  ohhh i see:) i think that now i understand it :D:D thx everyone;)

                  Mrozu

                  Comment

                  Working...