In the Prolog atoms backslash is a meta-character, i.e. if you want your atom to contain a backslash character then you need to escape it using the backslash character. E.g. in order to represent the Windows path \\fileserver\path\to\file.txt
as a Prolog atom you need to write
Path = '\\\\fileserver\\path\\to\\file.txt'.
In principle there are two ways of printing stuff out, one for the humans (pretty-printing), using write
?- Path = '\\\\fileserver\\path\\to\\file.txt', write(Path).
\\fileserver\path\to\file.txt
and one for the machines (serializing), using write_canonical
?- Path = '\\\\fileserver\\path\\to\\file.txt', write_canonical(Path).
'\\\\fileserver\\path\\to\\file.txt'
write_canonical
makes sure that Prolog can read the output back into the same exact atom.
Your problem seems to be that you do not correctly represent the path in Prolog. If the path comes from an external source, you first need to escape it (add a backslash in front of every backslash) before you can store it as a Prolog atom.