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

Problems with writing to txt file

I'm having problems writing to a text file. Basically it refuses to
write anything. The file is created. At the appropiate times it goes
into the correct if statements (I have verified this using msgboxes).
Any idea why it wouldnt be writing anything?

Do Until (objFacilitySht.Cells(row, cboAPName.Text).Value = "")
Dim fsStream As New FileStream(txtSaveto.Text & "\" &
objFacilitySht.Cells(row, cboAPName.Text).Value & ".txt",
FileMode.Create, FileAccess.Write)
Dim swWriter As New StreamWriter(fsStream)

' Start Writing Config files
Try
' Do until the end of the config sheet
counter = 1
Do Until (objConfigSht.Cells(counter, 1).Value = "")
If (InStr(objConfigSht.Cells(counter, 1).Value, "###")) Then
pound = objConfigSht.Cells(counter, 1).value.replace("#", "")

If pound = "1" Then
swWriter.WriteLine("!Revision " & Rev_date)

End If
Else
swWriter.WriteLine(objConfigSht.Cells(counter, 1).Value)

End If
counter += 1
Loop

swWriter.Close()

Catch ex As IOException

MsgBox(ex.Message)

End Try
row += 1
Loop

Nov 21 '05 #1
1 1125
Hi !
swWriter.Close()

Catch ex As IOException

MsgBox(ex.Message)

End Try


Is there an exception thrown.. ? if so then you didn't call the Close()
method, which should drop all the changes made to the file content.

try to call Close() in the Catch too :
'***
Try

' code code code...

swWriter.Close()

Catch ex As IOException

swWriter.Close()
MsgBox(ex.Message)

End Try
'***

--
Best Regards
Yanick
Nov 21 '05 #2

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

Similar topics

2
by: jfixsen | last post by:
Hello! Oracle 9.2.0.4 SunOS pchi-db01 5.8 Generic_108528-19 sun4u sparc SUNW,Ultra-EnterpriseSystem = SunOS Node = pchi-db01 Release = 5.8 KernelID = Generic_108528-19 Machine = sun4u...
1
by: Travis Stewart | last post by:
Hi, I've been working on some software to control an older GPIB card for the past couple of weeks. I have function prototypes in a header file pc-mate2.h and the functions are defined in...
4
by: HNguyen | last post by:
Hi, I have a Web application in ASP.NET. My Application allows the users upload files into the server after checking their user names and passwords. For each transaction, the Web program will...
3
by: poldoj | last post by:
First I would thank you all for the replies at my previous post. Say sorry for my poor english also. I have found where my problem came from. I am writing a string to a text box and write the...
2
by: Mike | last post by:
Hi, I am new to C and having problems with the following program. Basically I am trying to read some files, loading data structures into memory for latter searching. I am trying to use structres...
3
by: katz911 | last post by:
Hello, I've encountered a strange problem which I can't seem to explain. I've written a simple C++ class that deals with a certian binary file. In one of the methods there, I wish to update a...
409
by: jacob navia | last post by:
I am trying to compile as much code in 64 bit mode as possible to test the 64 bit version of lcc-win. The problem appears now that size_t is now 64 bits. Fine. It has to be since there are...
4
by: peterv6 | last post by:
I'm having problems writing records to an output file. When I do it in Textpad running on Windows, the output file looks fine. When, however, I copy the script to a Linux machine and use the exact...
0
by: Rob P | last post by:
Is there a reliable way of doing this? It seems that I am having problems with the data files being used by 'other' processes, despite them being custom to the application I'm writing. I'm sure...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 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 former...
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: 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
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: 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...

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.