Relative File Paths

Hi, I am trying to save files using a relative file path. I want the files to be saved in a folder called Data. If this folder does not exist, then I want the procedure to create it. For some reason when I run these two lines of code,
String newCSVFolder  = "::Data:"
NewPath/C/O saveFolder, location + newCSVFolder
<pre><code class="language-igor">

an error message is generated. The message says "The operation could not be completed because Windows OS error - Access Denied. Do you want help?"

When I change the String newCSVFolder to the full path name, the procedure performs precisely as I want it to.
It's not clear what is in location.

Quote:
When I change the String newCSVFolder to the full path name, the procedure performs precisely as I want it to

This makes me think that location is an empty string.

The path passed to NewPath must be a full path because Igor has no concept of a current directory.

Assuming that you know what your relative path is relative to, you should be able to convert your relative path to a full path.

If this does not solve the problem then create a demo function that illustrates the problem and specifies what you mean by "location" and what you want the path to be relative to.
I apologize for that typo. location originally held the full path to where I wished to create the folder called Data, but I want this code to work on any computer that I might use it on, not just mine.So for this case assume that location is "". Is there any way to create a folder just outside of whatever folder contains the experiment (.pxp) file? I just want to ascend one directory (in Java it would just be two periods "..Data").
Quote:
Is there any way to create a folder just outside of whatever folder contains the experiment (.pxp) file?

Yes. Here is how you do it:
// FullPathToHomeFolder()
// Returns colon-separated path to experiment's home folder with trailing colon
// or "" if there is no home folder.
Function/S FullPathToHomeFolder()
    PathInfo home
    if (V_flag == 0)
        // The current experiment was never saved so there is no home folder
        return ""
    endif

    String path = S_path
    return path
End

Function CreateFolderInHomeFolder(folderName, symbolicPathName)
    String folderName               // Name of folder to be created
    String symbolicPathName     // Name to use for the symbolic path
   
    String fullPath = FullPathToHomeFolder()
    if (strlen(fullPath) == 0)
        // Error - there is no home folder because the current experiment was never saved
        return -1
    endif
    fullPath += folderName
    NewPath/O/C $symbolicPathName, fullPath
    return 0                        // Success
End