|
-
July 30th, 2001, 06:29 AM
#1
Convert UNIX to DOS file
Hi,
I want to read an Input file that was generated from a UNIX system.
This is my code :
Open FicName for input as #1
Line input #1, FLigne
=> FicName (the file) and FLigne (string to hold the line read)
But when I read the first line of this file, I don't get only the first line and this give me a memory problem (too much information).
I know this is caused because some document generated from UNIX system do not terminate each line with a carriage return and a linefeed...
So I was wondering if anyone of you knows how to convert a UNIX file to a DOS format (with CR and LF...)??
I am able to convert it with an application (Ultra Edit) but I need to be able to do it in my application.
thanks a lot, really appreciate it!
Al
-
July 30th, 2001, 08:38 AM
#2
Re: Convert UNIX to DOS file
Private Function convertDOStoUNIX(DOSstring As String) As String
convertDOStoUNIX = Replace(DOSstring, vbCrLf, vbLf, 1, Len(DOSstring), vbTextCompare)
End Function
Private Function convertUNIXtoDOS(UNIXstring As String) As String
convertUNIXtoDOS = Replace(UNIXstring, vbLf, vbCrLf, 1, Len(UNIXstring), vbTextCompare)
End Function
Iouri Boutchkine
[email protected]
-
July 30th, 2001, 09:17 AM
#3
Re: Convert UNIX to DOS file
I don't think it's necessary to do the conversion at all. A UNIX file should have a line feed, if you use the FileSystemObject and the ReadLine method it will only pick up one line.
Set a reference to Microsoft Scripting Runtime.
Code would look like this:
Dim FSO as new FileSystemObject
Dim fsoStream as TextStream
Dim strLine as string
set fsoStream = FSO.OpenTextFile(YourFileName with full path here)
Do Until fsoStream.AtEndOfFile = true
strLine = fsoStream.ReadLine
Loop
fsoStream.Close
set FSO = nothing
That should do it.
-
July 30th, 2001, 09:46 AM
#4
Re: Convert UNIX to DOS 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
|