Most "normal" interactions with filenames these days can use forward slashes. 
But a sampling of edge cases still won't work that way:

- UNC paths like \\server\share\path can be finicky
- Long file paths (>260 characters) like \\?\path don't go both ways
- Device names like \\.\COM1 don't
- Loading DLLs often won't
- Calling the system function often won't support forward slashes... system 2 
usually will (depending on what executable you are actually calling)

I think the UNC, system and DLL cases are probably the ones most likely to bite 
an intermediate R user.

On May 7, 2026 7:53:49 PM PDT, Spencer Graves 
<[email protected]> wrote:
>See also:
>
>
>file.path(..., fsep = .Platform$file.sep)
>
>
>https://web.mit.edu/~r/current/lib/R/library/base/html/file.path.html
>
>
>I'm not sure, but help(".Platform") seems to support what I get from Richard 
>O'Keefe, that "you can safely use / in file name" perhaps no matter which 
>platform. At one point that was not true, but it may be the case now. Sorry: I 
>cannot easily check. Spencer Graves
>
>
>On 5/7/26 21:30, Richard O'Keefe wrote:
>> This isn't an R thing.  The Windows system calls that accept file names
>> accept both kinds of slash indifferently.  I've seen it said that this goes
>> back to MS-DOS 2, but certainly it's all NT versions.  If you need to link
>> C and/or Fortran with R, you can safely use / in file name strings in those
>> languages too.
>> 
>> On Fri, 8 May 2026 at 01:18, Chris Ryan <[email protected]> wrote:
>> 
>>> It had been about a year since I had worked in Windows, and apparently I
>>> had gotten rusty. Forward slashes in path names, as in
>>> 
>>> read.csv("e:/path/to/datafileOnWindows.csv")
>>> 
>>> work just fine in R on Windows.
>>> 
>>> Sorry for the bother.
>>> 
>>> --Chris Ryan
>>> 
>>> 
>>> 
>>> Chris Ryan wrote:
>>>> I'm trying to generalize one of my scripts so that it will run on my
>>>> Linux Mint computer at home and my client's Windows 11 computer at work.
>>>>   I'm encountering trouble when setting file paths, conditional on which
>>>> computer the script is running on. It's the Windows backslash issue
>>>> 
>>> 
>>> ______________________________________________
>>> [email protected] mailing list -- To UNSUBSCRIBE and more, see
>>> https://stat.ethz.ch/mailman/listinfo/r-help
>>> PLEASE do read the posting guide
>>> https://www.R-project.org/posting-guide.html
>>> and provide commented, minimal, self-contained, reproducible code.
>>> 
>> 
>>      [[alternative HTML version deleted]]
>> 
>> ______________________________________________
>> [email protected] mailing list -- To UNSUBSCRIBE and more, see
>> https://stat.ethz.ch/mailman/listinfo/r-help
>> PLEASE do read the posting guide https://www.R-project.org/posting-guide.html
>> and provide commented, minimal, self-contained, reproducible code.
>
>______________________________________________
>[email protected] mailing list -- To UNSUBSCRIBE and more, see
>https://stat.ethz.ch/mailman/listinfo/r-help
>PLEASE do read the posting guide https://www.R-project.org/posting-guide.html
>and provide commented, minimal, self-contained, reproducible code.

--
Sent from my phone. Please excuse my brevity.
        [[alternative HTML version deleted]]

______________________________________________
[email protected] mailing list -- To UNSUBSCRIBE and more, see
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide https://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.

Reply via email to