Error “Cannot delete file: Cannot read from the source file or disk”

I got asked this question by someone I can’t seem to reply to. Anyway the scenario involves Unix, Macs and PCs writing to the same Samba server.  The file attributes indicate readonly, hidden and system.  The use of the -force parameter will get PowerShell to display hidden/system files.  However the OP reports that Windows Explorer gets the same error.  This smells like invalided characters in the path.  This Microsoft KB article gives some guidance on this sort of problem in the "Invalid File Names" section.  If anyone else has run into this issue specifically, feel free to post a comment on how you eventually removed the offending files.

Advertisements
This entry was posted in PowerShell. Bookmark the permalink.

3 Responses to Error “Cannot delete file: Cannot read from the source file or disk”

  1. Larry says:

    Found the answer. Use Short file names. A program called "DelinvFile" by PurgeIE.com has a nice interface to get it done, plus some other directory naming errors. But you can use the Command shell to do it too if you know the 8.3 equivilant. Now to find the Powershell switch to use 8.3 name to "manage" files after recursively going thru a directory structure.

  2. Keith says:

    Larry, thanks for sharing your solution.  For those PSCX users, you can use Get-ShortPath to get the 8.3 short filename for a file. 

  3. Try using Long Path Tool .Here you can rename, delete, open and move your files instantly
    without the worries of ERROR messages saying you cannot delete file/cannot read from the source file or disk.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s