# Behavior of the pwd() statement, Windows 10

**URL:** https://discourse.julialang.org/t/behavior-of-the-pwd-statement-windows-10/19673
**Category:** General Usage
**Created:** [January 15, 2019, 6:39pm UTC](https://discourse.julialang.org/t/behavior-of-the-pwd-statement-windows-10/19673 "2019-01-15T18:39:49Z")
**Posts on this page:** 9
**Page:** 1

<div class="post-metadata">

### Author: ![Gunter\_Faes](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/gunter_faes/32/12580_2.png) [@Gunter\_Faes](https://discourse.julialang.org/u/Gunter_Faes)
#### Post date: [January 15, 2019, 6:39pm UTC](https://discourse.julialang.org/t/behavior-of-the-pwd-statement-windows-10/19673/1 "2019-01-15T18:39:49Z")

</div>

Hello,

The pwd statement has been discussed here before and I may not understand the answer. The following behavior can be found in the documentation:

```julia
julia> pwd()
"/home/JuliaUser"

```

When I execute the statement (Windows 10) I get the following output:

```julia
julia> pwd()
"C:\\Users\\guent\\AppData\\Local\\Julia-1.0.3"

```

In addition to the difference to the documentation this of course leads to an “ArgumentError” in the further using. Is this desired or is this a Julia malfunction? 😕

---

<div class="post-metadata">

### Author: ![fredrikekre](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/fredrikekre/32/1688_2.png) [@fredrikekre](https://discourse.julialang.org/u/fredrikekre)
#### Post date: [January 15, 2019, 6:44pm UTC](https://discourse.julialang.org/t/behavior-of-the-pwd-statement-windows-10/19673/2 "2019-01-15T18:44:02Z")

</div>

`pwd` returns the current working directory, see the [docs](https://docs.julialang.org/en/v1/base/file/#Base.Filesystem.pwd) which obviously will not be the same everywhere.

> [@Gunter\_Faes](#):
>
> leads to an “ArgumentError” in the further using.

What do you mean by this? What are you using the result for?

---

<div class="post-metadata">

### Author: ![Gunter\_Faes](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/gunter_faes/32/12580_2.png) [@Gunter\_Faes](https://discourse.julialang.org/u/Gunter_Faes)
#### Post date: [January 15, 2019, 6:51pm UTC](https://discourse.julialang.org/t/behavior-of-the-pwd-statement-windows-10/19673/3 "2019-01-15T18:51:45Z")

</div>

Thanks for your quick answer. For Julia, it’s of course a difference whether in a string a “/” or a “" character is contained. Under Windows 10 I even get the:”\"

If I now read the directory via pwd(), save it in a variable and then load a file later (by using of this variable), I get the error message mentioned above (or that this string does not describe a “file”). The reason is the “\” sign. If I replace it manually with “/” everything works. But it can’t be a solution, can it?

---

<div class="post-metadata">

### Author: ![Gunter\_Faes](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/gunter_faes/32/12580_2.png) [@Gunter\_Faes](https://discourse.julialang.org/u/Gunter_Faes)
#### Post date: [January 15, 2019, 6:53pm UTC](https://discourse.julialang.org/t/behavior-of-the-pwd-statement-windows-10/19673/4 "2019-01-15T18:53:07Z")

</div>

Sorry! My system lost "" and “\”…

---

<div class="post-metadata">

### Author: ![Gunter\_Faes](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/gunter_faes/32/12580_2.png) [@Gunter\_Faes](https://discourse.julialang.org/u/Gunter_Faes)
#### Post date: [January 15, 2019, 6:53pm UTC](https://discourse.julialang.org/t/behavior-of-the-pwd-statement-windows-10/19673/5 "2019-01-15T18:53:43Z")

</div>

What’s happend? “”"" and “”\“”…?

---

<div class="post-metadata">

### Author: ![Gunter\_Faes](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/gunter_faes/32/12580_2.png) [@Gunter\_Faes](https://discourse.julialang.org/u/Gunter_Faes)
#### Post date: [January 15, 2019, 6:55pm UTC](https://discourse.julialang.org/t/behavior-of-the-pwd-statement-windows-10/19673/6 "2019-01-15T18:55:07Z")

</div>

Sorry, take a look to my first post! You will see the character which I would like to “show”… 🤔

---

<div class="post-metadata">

### Author: ![ssfrr](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/ssfrr/32/3736_2.png) [@ssfrr](https://discourse.julialang.org/u/ssfrr)
#### Post date: [January 15, 2019, 6:59pm UTC](https://discourse.julialang.org/t/behavior-of-the-pwd-statement-windows-10/19673/7 "2019-01-15T18:59:55Z")

</div>

It would help to include a code snippet that is failing. It’s hard to know exactly what problem you’re having otherwise.

You shouldn’t need to manually replace the `\\` with `/` for things to work. Generally you should be using `joinpath` to create paths that work on your system, e.g. `joinpath(pwd(), "somefile.txt")` will create the proper absolute path for `"somefile.txt"` within your current directory.

---

<div class="post-metadata">

### Author: ![Tero\_Frondelius](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/tero_frondelius/32/7629_2.png) [@Tero\_Frondelius](https://discourse.julialang.org/u/Tero_Frondelius)
#### Post date: [January 15, 2019, 7:04pm UTC](https://discourse.julialang.org/t/behavior-of-the-pwd-statement-windows-10/19673/8 "2019-01-15T19:04:51Z")

</div>

```julia
julia> cd("C:\\Temp")

julia> cur_dir = pwd()
"C:\\Temp"

julia> open(joinpath(cur_dir,"tst.txt"),"w") do fil
           write(fil, "Hello World!")
       end
12

julia> open("tst.txt") do fil
         println(readline(fil))
       end
Hello World!

julia>

```

---

<div class="post-metadata">

### Author: ![Gunter\_Faes](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/gunter_faes/32/12580_2.png) [@Gunter\_Faes](https://discourse.julialang.org/u/Gunter_Faes)
#### Post date: [January 15, 2019, 7:21pm UTC](https://discourse.julialang.org/t/behavior-of-the-pwd-statement-windows-10/19673/9 "2019-01-15T19:21:54Z")

</div>

Many thanks for the joinpath statement! 😃 It works:

```julia
cur_dir = pwd()
dateiname ="Text.txt"
datei = open(joinpath(cur_dir, dateiname))
inhalt = readlines(datei)
close(datei)
println(inhalt)

Output:
["Das ist der 1. Text!", "Das ist der 2. Text!", "Das ist der 3. Text!"]

```
