I ran some code like this
(defun writeFile (name content)
(with-open-file (stream name
:direction :output
:if-exists :overwrite
:if-does-not-exist :create)
(format stream content)))
(writeFile "C:\Users\Peter\test.txt" "Test...")
but then I checked my C:\Users\Peter directory and it did not contain create a file named test.txt. What am I doing wrong?
\is an escape character in strings in Common Lisp.(length "\\")is1.(length "\U")is1."\U"is"U"."C:\Users\Peter\test.txt"is"C:UsersPetertest.txt".So you are writing a file called
"C:UsersPetertest.txt".Three possible solutions:
Advanced: use a logical pathname