How to insert a backslash between a folder + filename?

I have a script that works, but I can’t add my desired filename to the folder path:

FileN = GetFileNameWithoutExtension(sURL) & "\" & sSheetName & ".csv"

Interestingly, the highlight above indicates a syntax error, but not in the editor itself:

bild

However, the file operation on the above name fails until I remove the & " \ " and then it works, but of course it ends up in the wrong folder with a filename that begins with the folder name instead.

What’s the correct way of doing the above?

… is which operation exactly?

(Suspecting that you do something that expects a URL, while you create either an invalid URL with backslashes that are invalid in URLs, or a local path, which is again not a URL, and should be converted to one using ConvertToURL)

Another possible problem could be that the path (the directory) doesn’t exists before you use “the file operation”, and the directory should be created manually prior to creating files in it.

1 Like

Yeah, it was storeToURL and you’re right… an URL expects a forward slash and not a backslash and if I do that instead it works as expected. Thanks for making me see the error!

For posterity, the OP is using GetFileNameWithoutExtension() from the Tools library. This first requires a line like:

GlobalScope.BasicLibraries.loadLibrary("Tools")