|
-
Feb 4th, 2009, 06:02 PM
#1
Thread Starter
Hyperactive Member
[2005] Write a list to a text file
Code:
' total is a list
Dim string_array() As String
string_array = DirectCast(total.ToArray(GetType(String)), String())
File.AppendAllText("c:\test.txt", string_array)
Need help.
Thanks.
-
Feb 4th, 2009, 06:09 PM
#2
Addicted Member
Re: [2005] Write a list to a text file
Try this
vb Code:
'open stream writer
Dim objsw As New System.IO.StreamWriter("yourfile.txt")
Dim string_array() As String
Dim i As Integer = 0
'write array elements one per line
Do Until i = string_array.Length - 1
objsw.WriteLine(string_array(i))
'increment
i += 1
Loop
'close stream
objsw.Close()
Hope it helps!
Jesse Bunch
www.getbunch.com/
If I have helped you, please rate my posts!
Unless otherwise indicated, I am using the following Products:
Visual Studio .NET 2010
.NET Framework 4.0
-
Feb 4th, 2009, 06:13 PM
#3
Thread Starter
Hyperactive Member
Re: [2005] Write a list to a text file
I don't know why I get an error if I use Direcast
Code:
Overload resolution failed because no accessible 'ToArray' accepts this number of arguments.
Code:
string_array = DirectCast(total.ToArray(GetType(String)), String())
-
Feb 4th, 2009, 06:27 PM
#4
Thread Starter
Hyperactive Member
Re: [2005] Write a list to a text file
Okay. Ignore "DireCast(...)".
But only last row is wroten to the file.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|