# Joinpath() in wsl2 mounted drives

**URL:** <https://discourse.julialang.org/t/joinpath-in-wsl2-mounted-drives/80788>\
**Category:** General Usage\
**Created:** [May 10, 2022, 3:22am UTC](https://discourse.julialang.org/t/joinpath-in-wsl2-mounted-drives/80788 "2022-05-10T03:22:10Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![huang\_min](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/huang_min/32/34337_2.png) [@huang\_min](https://discourse.julialang.org/u/huang_min)\
**Post date:** [May 10, 2022, 3:22am UTC](https://discourse.julialang.org/t/joinpath-in-wsl2-mounted-drives/80788/1 "2022-05-10T03:22:11Z")

</div>

I would like to read/write files in a folder in D drives say D:\data. I hope it works for Julia both in windows and wsl2. I tried joinpath() but cannot figure out how to make it.

I start Julia in the home dir (or some project dir in various drives). I have explored @ **DIR** and homedir(). Can joinpath() or some other function achieve the requests below?

1. Under Ubuntu in wsl2, the home dir is “/home/workstation” and the file is in the mounted drive “/mnt/d/data”. How can I read.CSV(joinpath(…))?

2. Under Windows, the home dir is “C:\Users\workstation” and the file is in another drive: “D:\data”. How can I read.CSV(joinpath(…))?

3. Is there a uniform way to read files in the data folder of D drive no matter I start Julia from the home dir of Windows or Ubuntu?

I know I can do these by typing all the real paths, but I belive there should be some smart way.

---

<div class="post-metadata">

**Author:** ![albheim](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/albheim/32/34660_2.png) [@albheim](https://discourse.julialang.org/u/albheim)\
**Post date:** [May 10, 2022, 5:14am UTC](https://discourse.julialang.org/t/joinpath-in-wsl2-mounted-drives/80788/2 "2022-05-10T05:14:03Z")

</div>

You can check the operating system like [this](https://docs.julialang.org/en/v1/manual/handling-operating-system-variation/#Handling-Operating-System-Variation) and use that to just set a base path.

```julia
drivepath = Sys.iswindows() ? "D:" : "/mnt/d"
datapath = joinpath(drivepath, "data", ...)

```

If you can’t do a relative path and the absolute path is os specifik I think this might be the easiest/cleanest way.

---

<div class="post-metadata">

**Author:** ![huang\_min](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/huang_min/32/34337_2.png) [@huang\_min](https://discourse.julialang.org/u/huang_min)\
**Post date:** [May 10, 2022, 6:02am UTC](https://discourse.julialang.org/t/joinpath-in-wsl2-mounted-drives/80788/3 "2022-05-10T06:02:02Z")

</div>

Yeps, thanks, this should work. It seems to be a little hard for a relative path of different or mounted drives.
