|
-
Apr 14th, 2004, 03:40 PM
#1
Thread Starter
Lively Member
check if a file exits etc...
Okay, i need 2 make a list of winners. First, i would like to check if a certain file, (lstwinners.txt) exists. If it exists, it would add a certain string to the end of it. If it doesn't it would create it then add a string to the end. Please help!
-
Apr 14th, 2004, 04:26 PM
#2
Thread Starter
Lively Member
-
Apr 14th, 2004, 04:34 PM
#3
Frenzied Member
With all respect, do a little reading. This is basic file i/o and is covered in books, MSDN, google searches etc.
But to help out, why don't you just open the file in append mode and then write to it?
-
Apr 14th, 2004, 04:35 PM
#4
Thread Starter
Lively Member
Originally posted by Mike Hildner
With all respect, do a little reading. This is basic file i/o and is covered in books, MSDN, google searches etc.
But to help out, why don't you just open the file in append mode and then write to it?
i have a crappy textbook that doesnt tell me ****, and i would appreciate it if you could give me the exact code.. thanks
-
Apr 14th, 2004, 04:39 PM
#5
Frenzied Member
Well, that might be cheating. MSDN is a great resource, and it's on your machine/the web. Search for "File.Open Method", try out some examples, and if you still have troubles post the code you've tried and you'll get help.
-
Apr 14th, 2004, 05:08 PM
#6
Thread Starter
Lively Member
cheating? lol this is a program im making for fun! its for a game im making - a high score list if you will. please help. thanks
-
Apr 14th, 2004, 05:17 PM
#7
New Member
Hope to help...
Dim strPath As String = "C:\d.txt"
Dim SW As StreamWriter
Dim FS As FileStream
If File.Exists(strPath) = True Then
MsgBox("True")
FS = New FileStream(strPath, FileMode.Open)
SW = New StreamWriter(FS)
SW.WriteLine("True")
Else
MsgBox("False")
FS = New FileStream(strPath, FileMode.Create)
SW = New StreamWriter(FS)
SW.WriteLine("False")
End If
SW.Close()
FS.Close()
Things go better with rock
-
Apr 14th, 2004, 05:19 PM
#8
Thread Starter
Lively Member
works great xcept if it doesnt exist, i want it to create it AND write a line to it...
-
Apr 14th, 2004, 05:20 PM
#9
Frenzied Member
VB Code:
Dim sw As StreamWriter = New StreamWriter("c:\temp\myfile.txt", True)
sw.WriteLine("This is a simple example - MSDN is your friend!")
sw.Close()
-
Apr 14th, 2004, 05:30 PM
#10
Thread Starter
Lively Member
how do i load items from a txt file into a listbox? then im done!
-
Apr 14th, 2004, 05:42 PM
#11
New Member
Dim strPath As String = "C:\Items.txt"
Dim SR As StreamReader
Dim FS As FileStream
FS = New FileStream(strPath, FileMode.Open)
SR = New StreamReader(FS)
Dim itm As Object
itm = SR.ReadLine()
While Not itm = Nothing
Listbox1.Items.Add(itm)
itm = SR.ReadLine()
End While
SR.Close()
FS.Close()
Things go better with rock
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
|