Message 1 of 10
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
I'm trying to read a file that's written in normal ASCII characters and saved in Unicode format using the FileSystemObject leaning on the following methods
The code is simply like this
(defun read-unicode->ascii () (setq path "C:\\UserProfile\\somefolder\\test.txt") ;supply a real path instead ;Create the FileSystemObject (setq fso (vlax-create-object "Scripting.FileSystemObject")) (setq fobj (vlax-invoke-method 'OpenTextFile path 1 :vlax-true 0)) (setq txt (vlax-invoke-method fobj "ReadAll"))
(vlax-invoke-method fobj "Close") (mapcar 'vlax-object-release (list fso fobj)) (setq fso nil fobj nil) txt ;what to return );end-defun [read-unicode->ascii]
The issue is that
(vlax-invoke-method fobj "ReadAll")
Throws the error
; error: Automation Error. Description was not provided.
______________________
I've tried the methods that're responsible for writing text files, and they work fine.
______________________
P.S. The Autolisp function read-line returns the unicode equivalent result, but not the actual text that's written in normal ASCII, That's why I've decided to give the "FileSystemObject" a try.
______________
Any help and insightful responses are appreciated.
Solved! Go to Solution.