473,378 Members | 1,447 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,378 software developers and data experts.

Re: How to write a text file?


Thanks eBob

I'm looking at what i wrote and figured out that I should just change
the line I want to instead of just creating the file from scratch. So
poking around I ended up finding a Search and replace piece and i'm
using that. I'm not sure though if I should keep it as a class or do
I build it right into the form? SO far I'm getting pretty confused in
the UI and how to create something in Visual Studio. Although I
prepared for general confusion when I bought it, I didn't realise how
extremely different from batch/wsh/VBScript/Qbasic/Visual Basic it
would be. I'm looking around for a course now...

===========================
'
' sr = search and replace
'
Dim sr As StreamReader = New StreamReader( "autorun.ini" )
Dim fileText As String = sr.ReadToEnd()
Dim i As Integer = fileText.IndexOf("action4=\Documentation\Kit
\installplaceholder.html")
fileText = fileText.Remove(i, 1)
fileText = fileText.Insert(i,"exelocation_TextChanged")
sr.Close()

On Apr 10, 12:20*pm, "eBob.com" <eBob....@totallybogus.comwrote:
I would have started with Hello World, but to each his own. *But be aware
that the VS IDE can take a little bit of getting used to.

A nice thing about the VS IDE is the built in Help. *I just did a searchfor
"File i/o" and selected "Basic File I/O" from the hits and am looking at a
nice discussion of, well ..., basic file I/O. *(There are many things I
don't care for about the Help facility but it does contain a wealth of
information.)

The SAMS books lack depth, but if your programming experience is really
limited one of their books might be a good place to start.

Here's some code which I abstracted from a working program of mine.

* * * * Dim sw As StreamWriter * * * * * * *'for theoutput history file
* * * * Dim hisline As String * * * * * * * 'line tobe written to the
history file

* * * * sw = New StreamWriter(globalinf.ExcelFileName + ".his") * 'for the
output history file

* * * * sw.WriteLine(hisline)

* * * * sw.Close()

To use it you will also need an "Imports" statement ...

* * * * Imports System.IO

I'd recommend always using these two statements as the first two statements
in your source file:

* * * *Option Explicit On
* * * *Option Strict On

These two statements tell the compiler to catch your dumb errors at compile
time rather than allowing them to cause really confusing errors at run time.
(Although you will still experience really confusing errors at run time.)

Good Luck, *Bob
Jun 27 '08 #1
0 769

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

Similar topics

3
by: John Flynn | last post by:
hi, having problems reading from and writing back to the same file. basically, i want to read lines of text from a file and reverse them and write them back to the same file.. it has to...
1
by: Magix | last post by:
Hi, I have these string data: str_data1, str_data2, str_data3, which capture some value after a routine process A. Then I would like to write (append) these 3 string values into a text file each...
1
by: Jim Heimer | last post by:
Hi, I've been using schema.ini to read an ascii file to a dataset. Would it be possible to write to the ascii file the same way I read from it? In my case, the initial ascii file has two...
9
by: msuk | last post by:
All, I have a well form block of XML that is stored in a C# string type and I just simply want to display it in the browser using Response.Write but when I try this I get the following error: ...
10
by: Mike | last post by:
I have a text file that i need to write multiple lines of data to but one at a time. how can i write more then one line of data to the file? example: i do a search for a file on a server if the...
12
by: Nina | last post by:
Hi there, What is the maximum length that one line can hold in a text file using StreamWriter's Write or WriteLine method? If the string is too long for one line to hold, what will Write or...
4
by: Billy | last post by:
Hi all, I'm building a text file from a database table using the ASP Write Method and would like to position the cursor in a specific column position before writing the fields. As I loop through...
6
Atran
by: Atran | last post by:
Hello: In this article: You will learn to Write or Read A Text File. Let's Begin: First Create a new project (ConsoleApp or WinApp). And Make sure your program uses these namespaces: using...
6
by: globalrev | last post by:
i ahve a program that takes certain textsnippets out of one file and inserts them into another. problem is it jsut overwrites the first riow every time. i want to insert every new piece of...
65
by: Hongyu | last post by:
Dear all: I am trying to write to a file with full directory name and file name specified (./outdir/mytestout.txt where . is the current directory) in C programming language and under Unix, but...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
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...

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.