|
-
Jun 18th, 2000, 01:41 AM
#1
Thread Starter
Member
hi
i want to open a file and save all of it to a variable and then to write it to a new file.
how can i do it?
-
Jun 18th, 2000, 01:45 AM
#2
Code:
Function OpenFile(Filename As String) As String
On Error Resume Next
Open Filename For Input As #1
OpenFile = Input(LOF(1), 1)
Close #1
End Function
Private Sub SaveFile(Filename As String, Text As String)
On Error Resume Next
Open Filename For Output As #1
Print #1, Text
Close #1
End Sub
-
Jun 18th, 2000, 01:47 AM
#3
Lively Member
Open the file for binary access...
Ok, i hope i beat megatron to this... Here goes!
The following code shows how to read the contents of a file into a string (change to variant if ya want), then place them into a new file. If you just simply want to copy the file, then use filecopy:
Code:
FileCopy "C:\Test.txt", "C:\NewFile.txt"
Other wise, use the following code.
Code:
Dim strData as string
'Get Data
Open "C:\Test.txt" for binary as #1
strData = Space(LOF(1))
get #1, , strData
Close #1
'Put the data into a new file
Open "C:\MyNewFile.txt" For binary as #1
Put #1, strData
Close #1
Hope this helps...
Laterz
REM
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
|