M
M
Michael2020-05-18 13:47:45
Node.js
Michael, 2020-05-18 13:47:45

How can I read the file on another local machine?

Hello.

can you tell me how to read the file from the local machine?
It turns out that when I write
...path.join( '\\192.168.1.5\C$\ data\data.json' )
gives an error in the paths (access is open... but something seems to me that I need to escape the slashes tried so /\ nothing comes out,
thanks in advance!

Answer the question

In order to leave comments, you need to log in

1 answer(s)
D
Dmitry Belyaev, 2020-05-18
@rfhyjd

something seems to me that it is necessary to escape the slash tried like this /\ nothing comes out
Yes, the backslash needs to be escaped, since it is an escape character itself, while the forward slash does not escape, so nothing comes out
. Example:
\\ -> \
\\\\ -> \\
and the path module in the node is smart enough, to bring slashes in paths to those used in the system, so you can just
path.normalize( '//192.168.1.5/C$/data/data.json' )

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question