# Directory issue

**URL:** <https://discourse.julialang.org/t/directory-issue/111055>\
**Category:** General Usage\
**Tags:** filesystem\
**Created:** [March 2, 2024, 10:54am UTC](https://discourse.julialang.org/t/directory-issue/111055 "2024-03-02T10:54:29Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![Enlil50](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/enlil50/32/206539_2.png) [@Enlil50](https://discourse.julialang.org/u/Enlil50)\
**Post date:** [March 2, 2024, 10:54am UTC](https://discourse.julialang.org/t/directory-issue/111055/1 "2024-03-02T10:54:29Z")

</div>

This is a little code:

```julia
const file_path::String = "./try"
file_out = open(file_path, "w")
a::Int64 = 1
write(file_out, a)
close(file_out)

file_in = open(file_path, "r")
b::Int64 = read(file_in, Int64)
close(file_in)
println(b)

info = isdir(file_path)
println(info)
mkdir(file_path)

```

It creates and reads a binary file try (is it faster than saving it as txt?)  
The i wonder if I can create a folder, a directory, called try.  
A consistency check.  
isdir says there is no directory with this name and it’s right.  
However mkdir throws an error

---

<div class="post-metadata">

**Author:** ![barucden](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/barucden/32/26154_2.png) [@barucden](https://discourse.julialang.org/u/barucden)\
**Post date:** [March 2, 2024, 6:54pm UTC](https://discourse.julialang.org/t/directory-issue/111055/3 "2024-03-02T18:54:52Z")

</div>

`isdir(file_path)` returns `false` because `file_path` is not an existing directory – it is an existing _file_. You can use `isfile(file_path)` to test if `file_path` is an existing file, or `ispath(file_path)` to test if `file_path` exists at all (be it a file or a directory).

---

<div class="post-metadata">

**Author:** ![Enlil50](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/enlil50/32/206539_2.png) [@Enlil50](https://discourse.julialang.org/u/Enlil50)\
**Post date:** [March 2, 2024, 8:49pm UTC](https://discourse.julialang.org/t/directory-issue/111055/4 "2024-03-02T20:49:56Z")

</div>

If there is a file called Data, can’t I create a directory called Data too, or would they overlap for the system?

If I want to create a file and write data in binary to be fast, can I save the file as Data.txt instead?

This way there will be no overlap

---

<div class="post-metadata">

**Author:** ![barucden](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/barucden/32/26154_2.png) [@barucden](https://discourse.julialang.org/u/barucden)\
**Post date:** [March 2, 2024, 9:10pm UTC](https://discourse.julialang.org/t/directory-issue/111055/5 "2024-03-02T21:10:20Z")

</div>

> [@Enlil50](#):
>
> If there is a file called Data, can’t I create a directory called Data too, or would they overlap for the system?

Files and directories are referenced by their paths. If it were allowed to have a directory and a file at the same path, that path would not be unique and hence would be useless as a reference. So yes, if there is a file called `Data`, you cannot create a directory called `Data` (in the same directory).

> [@Enlil50](#):
>
> If I want to create a file and write data in binary to be fast, can I save the file as Data.txt instead?

A file’s suffix does not decide if the file’s content is binary or text. As long as you use the `write` function, the file will contain binary representation. For text representation, there is `print`.
