473,666 Members | 2,278 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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(txtS aveto.Text & "\" &
objFacilitySht. Cells(row, cboAPName.Text) .Value & ".txt",
FileMode.Create , FileAccess.Writ e)
Dim swWriter As New StreamWriter(fs Stream)

' Start Writing Config files
Try
' Do until the end of the config sheet
counter = 1
Do Until (objConfigSht.C ells(counter, 1).Value = "")
If (InStr(objConfi gSht.Cells(coun ter, 1).Value, "###")) Then
pound = objConfigSht.Ce lls(counter, 1).value.replac e("#", "")

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

End If
Else
swWriter.WriteL ine(objConfigSh t.Cells(counter , 1).Value)

End If
counter += 1
Loop

swWriter.Close( )

Catch ex As IOException

MsgBox(ex.Messa ge)

End Try
row += 1
Loop

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

Catch ex As IOException

MsgBox(ex.Messa ge)

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.Messa ge)

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
17407
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 BusType = <unknown>
1
11985
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 pc-mate2.c. I am using the Borland Turbo C 2.01 compiler (it is the compiler that the person I am writing this for uses) and when I compile the program I am writing I get an error: Turbo Link Version 2.0 Copyright (c) 1987, 1988 Borland...
4
2173
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 write the information about user name, filename upload, filesize, date and time of uploading into the log file. (The name of the log file is constructed by Current Year and Current Month in my program). Is there any problems with writing into the...
3
1180
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 content of that textbox to a file. All is just fine until I try to pass this character to the textbox: exemple: ------ TextBox1.AppendText(Chr(167) )
2
3270
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 and arrays of pointers to them. I have gotten the program to compile with gcc on WinXP. If the file i read doesnt have alot of records, it runs thru. But once i add more, it dies. In this program i have 4 files setup to read. The
3
1736
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 file - namely to read a certain field whose offset I know, and then write to another field, whose offset I also know. In order to read the data, I first use file.seekg(offset, ios::beg), and then a read command; I've checked the variable, and...
409
10977
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 objects that are more than 4GB long. The problem is, when you have in thousands of places
4
2235
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 same code, it appends a ^M character on each line written to the file. I have no idea why this is happening. I'm writing to the file by redirecting STDOUT to it. open STDOUT,"> ${output}" || die "$0 can't open $ifile"; This is how I'm...
0
1034
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 that I never had so many problems in c++ or Delphi, so is this a .net thing? It seems that even having Windows file explorer open on the same directory causes these problems? I'm currently considering writing a C++ or Delphi DLL to handle the...
0
8440
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8355
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
1
8550
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
8638
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
7381
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
4365
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
2769
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
2006
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
2
1769
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.