# Problem with creating files under the window path

**URL:** <https://forum.hdfgroup.org/t/problem-with-creating-files-under-the-window-path/12414>\
**Category:** HDFql\
**Created:** [June 14, 2024, 2:23pm UTC](https://forum.hdfgroup.org/t/problem-with-creating-files-under-the-window-path/12414 "2024-06-14T14:23:31Z")\
**Posts on this page:** 20\
**Page:** 1

<div class="post-metadata">

**Author:** ![meng\_1226](https://forum.hdfgroup.org/letter_avatar_proxy/v4/letter/m/a88e57/32.png) [@meng\_1226](https://forum.hdfgroup.org/u/meng_1226)\
**Post date:** [June 14, 2024, 2:23pm UTC](https://forum.hdfgroup.org/t/problem-with-creating-files-under-the-window-path/12414/1 "2024-06-14T14:23:31Z")

</div>

Can anyone help me on how to generate it with hdfql under windows. h5 file I run the code below generated below the specified directory. h5 file failed?

```
    private void BtnCreateHDF5_Click(object sender, RoutedEventArgs e)
    {
        Stopwatch sw = Stopwatch.StartNew();

        sw.Start();

        string pathname = "";
        string dbname = "F:\\test1\\hdf5_data.h5";

        ushort[,,] values = new ushort[1, 200, 800];
        
        //HDFql.Execute("USE DIRECTORY " + pathname);
        HDFql.Execute("CREATE FILE " + dbname);
        HDFql.Execute("USE FILE " + dbname);

        HDFql.Execute("CREATE GROUP /Data/GR-1 ORDER TRACKED");
        HDFql.Execute("CREATE CHUNKED(1,200, 800) DATASET /Data/GR-1/MyData " +
            "AS UNSIGNED SMALLINT(UNLIMITED, 200,800) ENABLE FLETCHER32");

        Random random = new Random();

        for (int i = 0; i < 200; i++)
        {
            for (int j = 0; j < 800; j++)
            {
                values[0, i, j] = (ushort)(random.Next(60000));
            }
        }

        HDFql.Execute("INSERT INTO /Data/GR-1/MyData VALUES FROM MEMORY "
            + HDFql.VariableTransientRegister(values));
        HDFql.Execute("CLOSE FILE");

        sw.Stop();
        TimeSpan ts = sw.Elapsed;
        string ss = "HDF5 Insert Data 10000: " + ts.TotalSeconds.ToString("0.0000");

        AddMemoInfo(ss);

    }

```

---

<div class="post-metadata">

**Author:** ![contact](https://forum.hdfgroup.org/user_avatar/forum.hdfgroup.org/contact/32/1067_2.png) [@contact](https://forum.hdfgroup.org/u/contact)\
**Post date:** [June 14, 2024, 10:19pm UTC](https://forum.hdfgroup.org/t/problem-with-creating-files-under-the-window-path/12414/2 "2024-06-14T22:19:23Z")

</div>

Hi @meng_1226,

Would you mind surrounding `dbname` with double-quotes as it contains special characters (e.g. `:`). In other words (and simplifying your code):

```auto
HDFql.Execute("CREATE AND USE FILE \"" + dbname + "\"");

```

Hope it helps!

---

<div class="post-metadata">

**Author:** ![meng\_1226](https://forum.hdfgroup.org/letter_avatar_proxy/v4/letter/m/a88e57/32.png) [@meng\_1226](https://forum.hdfgroup.org/u/meng_1226)\
**Post date:** [June 15, 2024, 1:06am UTC](https://forum.hdfgroup.org/t/problem-with-creating-files-under-the-window-path/12414/3 "2024-06-15T01:06:58Z")

</div>

```
        string dbname = "\"F:\\test1\\hdf5_data.h5\"";
        
        //HDFql.Execute("USE DIRECTORY " + pathname);
        HDFql.Execute("CREATE FILE " + dbname);
        HDFql.Execute("USE FILE " + dbname);

```

To still create the F:\test1\hdf5\_data.h5 file has failed,  
HDFql. Execute Execution is returned as fail

---

<div class="post-metadata">

**Author:** ![contact](https://forum.hdfgroup.org/user_avatar/forum.hdfgroup.org/contact/32/1067_2.png) [@contact](https://forum.hdfgroup.org/u/contact)\
**Post date:** [June 15, 2024, 6:58am UTC](https://forum.hdfgroup.org/t/problem-with-creating-files-under-the-window-path/12414/4 "2024-06-15T06:58:16Z")

</div>

Hi @meng_1226,

Do you have access to `F:\\test1`? Also, would you mind to share the return code of `Execute` as follows:

```auto
Console.WriteLine(HDFql.Execute("CREATE FILE " + dbname));

```

---

<div class="post-metadata">

**Author:** ![meng\_1226](https://forum.hdfgroup.org/letter_avatar_proxy/v4/letter/m/a88e57/32.png) [@meng\_1226](https://forum.hdfgroup.org/u/meng_1226)\
**Post date:** [June 15, 2024, 7:08am UTC](https://forum.hdfgroup.org/t/problem-with-creating-files-under-the-window-path/12414/5 "2024-06-15T07:08:04Z")

</div>

Uploading: ret.png…  
return = -4

---

<div class="post-metadata">

**Author:** ![meng\_1226](https://forum.hdfgroup.org/letter_avatar_proxy/v4/letter/m/a88e57/32.png) [@meng\_1226](https://forum.hdfgroup.org/u/meng_1226)\
**Post date:** [June 15, 2024, 7:09am UTC](https://forum.hdfgroup.org/t/problem-with-creating-files-under-the-window-path/12414/6 "2024-06-15T07:09:33Z")

</div>

![ret](https://dbkt.hdfgroup.org/original/2X/4/49cc566670145ab145c375c342dc914e8e140c3b.jpeg)

---

<div class="post-metadata">

**Author:** ![contact](https://forum.hdfgroup.org/user_avatar/forum.hdfgroup.org/contact/32/1067_2.png) [@contact](https://forum.hdfgroup.org/u/contact)\
**Post date:** [June 15, 2024, 10:02am UTC](https://forum.hdfgroup.org/t/problem-with-creating-files-under-the-window-path/12414/7 "2024-06-15T10:02:28Z")

</div>

Thanks for sharing the return code.

According to HDFql [reference manual](https://www.hdfql.com/resources/HDFqlReferenceManual.pdf), return code `-4` (HDFQL\_ERROR\_NO\_ACCESS) means that a directory, file or object cannot be accessed.

Are you sure to have access to `F:\\test1`?

---

<div class="post-metadata">

**Author:** ![meng\_1226](https://forum.hdfgroup.org/letter_avatar_proxy/v4/letter/m/a88e57/32.png) [@meng\_1226](https://forum.hdfgroup.org/u/meng_1226)\
**Post date:** [June 15, 2024, 11:00am UTC](https://forum.hdfgroup.org/t/problem-with-creating-files-under-the-window-path/12414/8 "2024-06-15T11:00:19Z")

</div>

maybe windows path problem, HDFql using posix!

---

<div class="post-metadata">

**Author:** ![contact](https://forum.hdfgroup.org/user_avatar/forum.hdfgroup.org/contact/32/1067_2.png) [@contact](https://forum.hdfgroup.org/u/contact)\
**Post date:** [June 15, 2024, 12:30pm UTC](https://forum.hdfgroup.org/t/problem-with-creating-files-under-the-window-path/12414/9 "2024-06-15T12:30:25Z")

</div>

Would you mind trying `string dbname = "\"F:\\\\test1\\hdf5_data.h5\"";` or `string dbname = @“”"F:\\test1\\hdf5_data.h5\"”";` and see how it goes?

---

<div class="post-metadata">

**Author:** ![meng\_1226](https://forum.hdfgroup.org/letter_avatar_proxy/v4/letter/m/a88e57/32.png) [@meng\_1226](https://forum.hdfgroup.org/u/meng_1226)\
**Post date:** [June 15, 2024, 1:21pm UTC](https://forum.hdfgroup.org/t/problem-with-creating-files-under-the-window-path/12414/10 "2024-06-15T13:21:39Z")

</div>

Thanks so much for your reply, but still not

---

<div class="post-metadata">

**Author:** ![contact](https://forum.hdfgroup.org/user_avatar/forum.hdfgroup.org/contact/32/1067_2.png) [@contact](https://forum.hdfgroup.org/u/contact)\
**Post date:** [June 15, 2024, 2:54pm UTC](https://forum.hdfgroup.org/t/problem-with-creating-files-under-the-window-path/12414/11 "2024-06-15T14:54:38Z")

</div>

Would you mind checking if you have access to `F:\\test1`?

---

<div class="post-metadata">

**Author:** ![meng\_1226](https://forum.hdfgroup.org/letter_avatar_proxy/v4/letter/m/a88e57/32.png) [@meng\_1226](https://forum.hdfgroup.org/u/meng_1226)\
**Post date:** [June 15, 2024, 11:48pm UTC](https://forum.hdfgroup.org/t/problem-with-creating-files-under-the-window-path/12414/12 "2024-06-15T23:48:52Z")

</div>

The test program I wrote is available in D:\projects\hdftest1,  
If I use this  
string dbname = “hdf5\_data.h5”;  
He can generate a file under the directory of the program, but not if he changes the disk character

---

<div class="post-metadata">

**Author:** ![meng\_1226](https://forum.hdfgroup.org/letter_avatar_proxy/v4/letter/m/a88e57/32.png) [@meng\_1226](https://forum.hdfgroup.org/u/meng_1226)\
**Post date:** [June 15, 2024, 11:49pm UTC](https://forum.hdfgroup.org/t/problem-with-creating-files-under-the-window-path/12414/13 "2024-06-15T23:49:58Z")

</div>

F: \test1 This directory can be accessed

---

<div class="post-metadata">

**Author:** ![meng\_1226](https://forum.hdfgroup.org/letter_avatar_proxy/v4/letter/m/a88e57/32.png) [@meng\_1226](https://forum.hdfgroup.org/u/meng_1226)\
**Post date:** [June 16, 2024, 4:30am UTC](https://forum.hdfgroup.org/t/problem-with-creating-files-under-the-window-path/12414/14 "2024-06-16T04:30:23Z")

</div>

Is it a problem with the posix style path???

---

<div class="post-metadata">

**Author:** ![meng\_1226](https://forum.hdfgroup.org/letter_avatar_proxy/v4/letter/m/a88e57/32.png) [@meng\_1226](https://forum.hdfgroup.org/u/meng_1226)\
**Post date:** [June 20, 2024, 9:59am UTC](https://forum.hdfgroup.org/t/problem-with-creating-files-under-the-window-path/12414/15 "2024-06-20T09:59:47Z")

</div>

Who can help me to be appreciated!!

---

<div class="post-metadata">

**Author:** ![andrew\_fisher](https://forum.hdfgroup.org/letter_avatar_proxy/v4/letter/a/a5b964/32.png) [@andrew\_fisher](https://forum.hdfgroup.org/u/andrew_fisher)\
**Post date:** [September 2, 2024, 9:14am UTC](https://forum.hdfgroup.org/t/problem-with-creating-files-under-the-window-path/12414/16 "2024-09-02T09:14:15Z")

</div>

I also see this problem when using HDFql. I cannot use paths which include a drive letter (or UNC paths).  
“\directory\filename.hdf5” is OK  
“C:\directory\filename.hdf5” fails with error code -4

To work around this problem with your example F:\test1\hdf5\_data.h5 :

- check if file path starts with drive letter ( F:)
  - push current working directory
  - remove drive letter: from filename (leaving \test1\hdf5\_data.h5 in your example)
  - change working directory to drive letter (F:)
  - perform desired HDFql operation using filename without drive letter
  - pop to original working directory

You’ll need to wrap this around any HDFql operations which specify a filename such as CREATE, USE, CLOSE, DROP

It would be very nice if HDFql did this for us!

---

<div class="post-metadata">

**Author:** ![contact](https://forum.hdfgroup.org/user_avatar/forum.hdfgroup.org/contact/32/1067_2.png) [@contact](https://forum.hdfgroup.org/u/contact)\
**Post date:** [September 3, 2024, 7:54am UTC](https://forum.hdfgroup.org/t/problem-with-creating-files-under-the-window-path/12414/17 "2024-09-03T07:54:13Z")

</div>

Hi @meng_1226 and @andrew_fisher,

Would you mind surrounding the path/file name with `"` (as it contains the reserved character `:` from [HDFql](https://www.hdfql.com) point of view) and escaping all its `\` (as `\` is a reserved character in C#)? In other words, please try the following and see if it works properly now:

```auto
HDFql.Execute("USE FILE \"F:\\test1\\hdf5_data.h5\"");

```

Hope it helps!

---

<div class="post-metadata">

**Author:** ![andrew\_fisher](https://forum.hdfgroup.org/letter_avatar_proxy/v4/letter/a/a5b964/32.png) [@andrew\_fisher](https://forum.hdfgroup.org/u/andrew_fisher)\
**Post date:** [September 3, 2024, 2:13pm UTC](https://forum.hdfgroup.org/t/problem-with-creating-files-under-the-window-path/12414/18 "2024-09-03T14:13:20Z")

</div>

Thanks for the suggestion.

Using quotes around the path / filename does not fix this issue. It allows a drive letter to be included in the path, but the file will only be successfully created / opened if my program is running from the same drive letter.

Program running from C: drive, quoted path with drive letter on C: drive  
HDFql::execute(“CREATE TRUNCATE AND USE FILE \“C:\\test1\\filename.hdf5\””);  
–Success

Program running from D: drive, quoted path with drive letter on D: drive  
HDFql::execute(“CREATE TRUNCATE AND USE FILE \“D:\\test1\\filename.hdf5\””);  
–Success

Program running from C: drive, quoted path with drive letter on D: drive  
HDFql::execute(“CREATE TRUNCATE AND USE FILE \“D:\\test1\\filename.hdf5\””);  
Error code -4

Program running from D: drive, quoted path with drive letter on C: drive  
HDFql::execute(“CREATE TRUNCATE AND USE FILE \“C:\\test1\\filename.hdf5\””);  
Error code -4

Unquoted path including drive letter  
HDFql::execute(“CREATE TRUNCATE AND USE FILE C:\\test1\\filename.hdf5”);  
–Error code -1

I’m using HDFql 2.5.0 with C++

---

<div class="post-metadata">

**Author:** ![contact](https://forum.hdfgroup.org/user_avatar/forum.hdfgroup.org/contact/32/1067_2.png) [@contact](https://forum.hdfgroup.org/u/contact)\
**Post date:** [September 4, 2024, 5:11am UTC](https://forum.hdfgroup.org/t/problem-with-creating-files-under-the-window-path/12414/19 "2024-09-04T05:11:55Z")

</div>

Hi @andrew_fisher,

Thanks for the detailed report!

At our side, we tested [HDFql](https://www.hdfql.com) using different drives (i.e. running a program on one drive and creating and accessing an HDF5 file on another drive) and it worked perfectly fine. Given that you are working in C/C++, would you mind running your test cases once more, this time using the HDF5 library function [H5Fcreate](https://docs.hdfgroup.org/hdf5/v1_12/group___h5_f.html#title9) to create and access an HDF5 file and see how it goes? Just to understand where the issue lies.

---

<div class="post-metadata">

**Author:** ![contact](https://forum.hdfgroup.org/user_avatar/forum.hdfgroup.org/contact/32/1067_2.png) [@contact](https://forum.hdfgroup.org/u/contact)\
**Post date:** [October 1, 2024, 7:47pm UTC](https://forum.hdfgroup.org/t/problem-with-creating-files-under-the-window-path/12414/20 "2024-10-01T19:47:48Z")

</div>

Hi @andrew_fisher,

Have you had a chance to try out the (problematic) use-case with the HDF5 library function yet?
