Skip to content

[Feature Request]: trashItem can't use POSIX separator on Windows #28831

Closed as not planned

Description

@WingDust

Preflight Checklist

Problem Description

   const fs = require('fs')  
   console.log(
     fs.existsSync('G:/1.txt')
   );
   shell.trashItem('G:/1.txt').catch((reason)=>{
        console.log(reason);
    })
   shell.trashItem('G:\\1.txt').catch((reason)=>{
        console.log(reason);
    })

second trashItem will error [Error: Failed to parse path] in Windows

Proposed Solution

shell.trashItem('G:/1.txt').catch((reason)=>{
        console.log(reason);
  })

should direct support in Windows

Alternatives Considered

   shell.trashItem('G:\\1.txt').catch((reason)=>{
        console.log(reason);
    })

Additional Information

none

Activity

  1. changed the title [-][Feature Request]: trashItem can't use POSIX separator in Windows[/-] [+][Feature Request]: trashItem can't use POSIX separator on Windows[/+] on Apr 25, 2021
  2. MarshallOfSound commented on Apr 25, 2021

    @MarshallOfSound
    Member

    This is currently expected behavior, Electron APIs that take in file paths required resolved paths with the correct path separators.

    This is very easy to do with path.resolve but supporting posix paths on windows comes with a myriad of edge cases that I'd rather not introduce to Electrons API surface

  3. WingDust commented on Apr 26, 2021

    @WingDust
    Author

    if that Should explain in Doc with trashItem

  4. miniak commented on Jun 25, 2021

    @miniak
    Contributor

    @WingDust you can contribute the documentation change with a PR

  5. MarshallOfSound commented on Nov 13, 2022

    @MarshallOfSound
    Member

    Closing per the comment in #28831 (comment)

    If someone wants to add docs around this PRs welcome, but the change to support posix paths is not something we'll do

  6. sammarshallou commented on Nov 21, 2025

    @sammarshallou
    Contributor

    This also caught me out - it is a bit strange because all other fs APIs I've used in my app do work correctly with forward or mixed slashes. It's also a bit surprising because the native Win32 APIs (in C++, etc) do usually support both types of slash. I'll see how easy it is to submit a documentation change.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions