473,326 Members | 2,127 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,326 software developers and data experts.

Can't write to file

I am trying to use the streamwriter to write to a text file

I declare the streamwriter publically at the beginning

im filename As String

Dim Drive As String

Dim oFile As System.IO.File

Dim ofile2 As System.IO.File

Dim nopatch As System.IO.StreamWriter

Dim error1 As System.IO.StreamWriter

Dim testfile As System.IO.StreamWriter

Dim dir As String

After a button click I try to write some data ased on conditions. The files
appear but they are empty. I check the values of the variables and they all
of text associated

'create the initial output files and directories

dir = TextBox3.Text & "\"

Directory.CreateDirectory(dir)

nopatch = oFile.CreateText(dir & "nopatch.txt")

error1 = ofile2.CreateText(dir & "error.txt")

testfile = oFile.CreateText("C:\output\test.txt")

testfile.WriteLine("test")

Actual Write process

Catch ex As Exception

exout = ex.ToString

errorout = computer & "," & servername & "," & exout

error1.WriteLine(errorout)

testfile.WriteLine("test")

testfile.WriteLine(errorout)

End Try


Nov 21 '05 #1
2 1537
* "Microsoft" <ma*@mas.com> scripsit:
I am trying to use the streamwriter to write to a text file


What doesn't work? Error message?

--
M S Herfried K. Wagner
M V P <URL:http://dotnet.mvps.org/>
V B <URL:http://dotnet.mvps.org/dotnet/faqs/>
Nov 21 '05 #2
No error messages, but I figured out that it doesn't write to the file until
I close it. So I am using the append method followed by a close.
"Herfried K. Wagner [MVP]" <hi***************@gmx.at> wrote in message
news:u9**************@TK2MSFTNGP10.phx.gbl...
* "Microsoft" <ma*@mas.com> scripsit:
I am trying to use the streamwriter to write to a text file


What doesn't work? Error message?

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

Nov 21 '05 #3

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

Similar topics

5
by: Norman Fritag | last post by:
Hi there, The Problem: I can't write data to an access database in a webfolder of a windows Prof 2000 machine, whereas the same web application runs fine under Windows XP. I looked into the...
2
by: clintonG | last post by:
The application is a simple form of three textbox controls that results in writing an XML file to the file system of the application root when it runs on the local development machine. I've just...
3
by: Shabam | last post by:
I'm running Dotnet on Windows 2003 and was wondering, can scripts write to files/folders outside of the webroot, for instance, in another drive? How about writing to a network share via UNC? Is...
5
by: Martin McCormick | last post by:
I am obviously confused about how to write to the file created by the mkstemp function. The manual says that it returns a pointer to a file descripter when successful and I think that the...
3
by: belange | last post by:
I try to create a little web application with c# and visual studio.net. With this application, a student can reserved a computer station, the day and the hour. I want to write these informations in...
4
by: feng | last post by:
..Net's .config file is supposed to replace the .ini files. That's all fine if all I need is to read from it. But what if I need both read and write? With .ini file, I can do that very easily with...
2
by: Alex | last post by:
Yes you can: <html><head><script language="javascript"> SaveToFile('This is a text to save in a file', 'C:\\temp\\test.txt'); alert(read('C:\\temp\\test.txt')); function SaveToFile (text,...
3
by: ayham | last post by:
I can't Write to XML File using ASP.NET becouse my OS(win xp) tell me that the user(account) that is ASP.net haven't the right to access the file -- ayham...
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...
0
by: Swan | last post by:
Can anyone plz tell me,Can I write file on server using binary access,or it is only to write on local?(Actually I am creating OCX for Http File Upload Control in VB using API's.So for that I need to...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
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...
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
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...

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.