PDA

Click to See Complete Forum and Search --> : A Set Number Of Lines In Text File


Eric M
Jan 28th, 2000, 10:03 AM
I need to find a way to add a file to the top of a text file that is going to be a list of files recently used documents. Or a way to read the file from the bottom to the top.

[This message has been edited by Eric M (edited 01-28-2000).]

OneSource
Jan 28th, 2000, 11:08 AM
Hi Eric M.

I believe that this code does what you are looking for.Option Explicit

Private Sub Command1_Click()
Dim stFiles() As String
Dim iCounter As Integer

'Read the current file into an array
Open "C:\YourTextFile.txt" For Input As #1

Do Until EOF(1)
ReDim Preserve stFiles(iCounter)
Input #1, stFiles(iCounter)
iCounter = iCounter + 1
Loop

Close #1

'Put the new file name at the top of the text file
Open "C:\YourTextFile.txt" For Output As #1

Write #1, "New File Name"
For iCounter = 0 To UBound(stFiles)
Write #1, stFiles(iCounter)
Next iCounter

Close #1
End SubAll the best.

------------------
OneSource
The truth may be out there, but it's in here too!.


[This message has been edited by OneSource (edited 01-29-2000).]

cas21
Jan 28th, 2000, 12:26 PM
You could use the registry instead of a text file to save a recent file list.