473,396 Members | 2,076 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

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.StreamWriter("C:\text.txt")

sw.write("Hello")

..
..
..
..

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

thx Mrozu

Nov 21 '05 #1
8 1277
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.StreamWriter("C:\TextFile.txt")

sw.Write(Convert.ToChar(34) & "Hello" & Convert.ToChar(34))
I'm sure the experts in this group can suggest better methods...

______________________________________
The Grim Reaper

"Mrozu" <gm****@yahoo.pl> wrote in message
news:11*********************@o13g2000cwo.googlegro ups.com...
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.StreamWriter("C:\text.txt")

sw.write("Hello")

.
.
.
.

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

thx Mrozu

Nov 21 '05 #2
"Mrozu" <gm****@yahoo.pl> schrieb:
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.StreamWriter("C:\text.txt")

sw.write("Hello")

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


'sw.Write("""Hello""")'.

--
M S Herfried K. Wagner
M V P <URL:http://dotnet.mvps.org/>
V B <URL:http://classicvb.org/petition/>
Nov 21 '05 #3
Thanks Grim Reaper. It works :)

Thx Mrozu

Nov 21 '05 #4
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...
Nov 21 '05 #5
Personal preference - to me that makes code very unreadable!

Especially with ASP scripts.

__________________________________
The Grim Reaper

"Alex C. Barberi" <we*******@visionforceweb.com> wrote in message
news:ex**************@TK2MSFTNGP10.phx.gbl...
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...

Nov 21 '05 #6
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

Nov 21 '05 #7
"Mrozu" <gm****@yahoo.pl> schrieb:
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:)

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/>

Nov 21 '05 #8
ohhh i see:) i think that now i understand it :D:D thx everyone;)

Mrozu

Nov 21 '05 #9

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
by: Ben Kial | last post by:
I need to write a program to "copy" files and preserved the files' atime, mtime, ctime, file permissions. I also need to have this program working in Unix and Windows, where the "Archive"...
2
by: Johan Kohler | last post by:
Hi, I have a class with attributes that are string, integer and list. eg. class person: name ="" age = 0 friends= comment=""""""
1
by: Mark Richards | last post by:
The solutions for the following problems seems to be simple but I did not found a (convenient) solution: Assume we have a number of elements of the same type under a common parent e.g. <person...
1
by: Daniel | last post by:
If my System.IO.StreamWriter Write method throws "The specified network name is no longer available." and I try to Dispose or Close it in the finaly clause the close or dispose method just throws...
7
by: samuelberthelot | last post by:
Hi, I have the following in my asp page: <% response.write(Header) %> where Header contains HTML markup such ass <html> <body> .... I must write the code in the aspx file and not in the...
1
by: =?Utf-8?B?R2FuZXNoIE11dGh1dmVsdQ==?= | last post by:
Hello All, Our application write logs to a file in a folder. Before our application starts writing to that file, I want to check if the current user has write access to that file, for example,...
2
by: babakandme | last post by:
Hi to every body...:D I'm a novice C++ programmer & I've a question, How can I write a class as follow to a file... Class A { public: // Accessors Methods...
1
by: Curious | last post by:
I want to write to an output file, "C:\\temp\\debug.txt": If the file exists, append the new content to the end of the file (instead of overwriting the current content). If the file doesn't exist,...
1
by: pauld | last post by:
Hello - I have created a simple web application in VS 2005/ASP.net 2.0 for a university department to track problems with a new website that I have built for them. The app consists of an Access...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.