Post a reply

Options
Add an Attachment

If you do not want to add an Attachment to your Post, please leave the Fields blank.

(maximum 10 MB; please compress large files; only common media, archive, text and programming file formats are allowed)

Options

Topic review

abd1111

Nevermind, issues seemed to have solved themselves for now after several OneDrive re-boots and global Autosave on Office products set to 'Off'
abd1111

I will scrap that issue for now, as I have a somewhat related issue now with bringing files in. Using that same code snippet above as the code ran, I get completely random file sync errors with OneDrive. When I run the code, some of the new files it brings over AND random older files get a merge/sync error with OneDrive as if it detects two different versions of random files (zero other copies exist anywhere). I checked for any timestamp discrepancies on files vs FTP version and any dupes on the PC already, but there is nothing. At a loss. The timestamps in the image are the same. No one has ever saved or overwritten the files since uploading on FTP.
...can I also rule out the code for this error and contact MS for OneDrive help?
martin

Re: "System Error. Code: 395. Access to the cloud file is denied"

This definitely has nothing to do with anything in your code.
So do you say that WinSCP downloads successfully other files in that directory, but not this specific file? Is it persistent? Does the script terminate always on the same file? Can you post session log file that shows successful download of other file from that directory followed by the failure?
abd1111

"System Error. Code: 395. Access to the cloud file is denied"

Hello again. I have a download script running on PowerShell, and encountered a bizarre error I've never seen before. The downloads GO to a Microsoft SharePoint folder that I have synced to my local C drive, and I can access it and open it with no problem locally and remotely. The file in question was downloaded, but why would it say it can't OPEN the file and then terminate the script?

"2024-11-13 18:43:57 - Exception calling "Check" with "0" argument(s): "Can't open file 'C:\Users\UserName\CoName\HealthCare - Eligibility Files\CoName1\0- Initial Eligibility\11.10.24 CoName2 Elig - xx.csv'.
System Error. Code: 395.
Access to the cloud file is denied"

(Had to redact some info)

Here is my portion of the script that ran it:
try
{
    Add-Type -Path "C:\Program Files (x86)\WinSCP\WinSCPnet.dll"   
 
    $sessionOptions = New-Object WinSCP.SessionOptions -Property @{
        Protocol = [WinSCP.Protocol]::Sftp
        HostName = "x"
        UserName = "x"
        Password = "x"
        SshHostKeyFingerprint = "x"
    }
 
    $session = New-Object WinSCP.Session
    $remotePath = "/Co.Name/Carrier/0 - Initial Eligibility Upload to x/"
    $localPath = "C:\Users\UserName\Co.Name1\HealthCare Files\Co.Name\0- Initial Eligibility\"
 
    # Connect
    $session.Open($sessionOptions)
    $session.Timeout = New-TimeSpan -Seconds 1000
 
    # Masking
    $transferOptions = New-Object WinSCP.TransferOptions
    $transferOptions.FileMask = "*.*"
 
    # Download files
    $transferOptions.AddRawSettings("ExcludeEmptyDirectories", "1")
    $transferOptions.AddRawSettings("NewerOnly", "1")
    $session.GetFiles($remotePath, $localPath, $False, $transferOptions).Check()
}
catch
{
    Write-Host "$_"
    $ErrorMessage = $_.Exception.Message
    $TimeStamp = Get-Date -Format "yyyy-MM-dd HH:mm:ss"
    $LogMessage = "$TimeStamp - $ErrorMessage"
    Add-Content -Path "C:\Users\UserName\Documents\FTP Project LOGS\ErrorFileLog.txt" -Value $LogMessage
}
finally
{
    # Disconnect, clean up
    $session.Dispose()
}

Part of the log file in question:
< 2024-11-14 18:42:58.099 Type: SSH_FXP_STATUS, Size: 17, Number: 4450820
. 2024-11-14 18:42:58.099 Discarding reserved response
< 2024-11-14 18:42:58.225 Type: SSH_FXP_HANDLE, Size: 45, Number: 4451075
> 2024-11-14 18:42:58.225 Type: SSH_FXP_FSTAT, Size: 45, Number: 4451336
< 2024-11-14 18:42:58.282 Type: SSH_FXP_ATTRS, Size: 29, Number: 4451336
* 2024-11-14 18:42:58.282 (EOSError) System Error.  Code: 395.
* 2024-11-14 18:42:58.282 Access to the cloud file is denied
. 2024-11-14 18:42:58.282 Asking user:
. 2024-11-14 18:42:58.282 Can't open file 'C:\Users\UserName\CoName\HealthCare - Eligibility Files\CoName1\0- Initial Eligibility\11.10.24 CoName2 Elig - xx.csv'. ("System Error.  Code: 395.
. 2024-11-14 18:42:58.282 Access to the cloud file is denied")
< 2024-11-14 18:42:58.282 Script: Can't open file 'C:\Users\UserName\CoName\HealthCare - Eligibility Files\CoName1\0- Initial Eligibility\11.10.24 CoName2 Elig - xx.csv'.
< 2024-11-14 18:42:58.282 Script: System Error.  Code: 395.
< 2024-11-14 18:42:58.282 Access to the cloud file is denied
. 2024-11-14 18:42:58.282 Answer: Abort
> 2024-11-14 18:42:58.282 Type: SSH_FXP_CLOSE, Size: 45, Number: 4451588
* 2024-11-14 18:42:58.282 (ESkipFile) Can't open file 'C:\Users\UserName\CoName\HealthCare - Eligibility Files\CoName1\0- Initial Eligibility\11.10.24 CoName2 Elig - xx.csv'.
* 2024-11-14 18:42:58.282 System Error.  Code: 395.
* 2024-11-14 18:42:58.282 Access to the cloud file is denied
. 2024-11-14 18:42:58.282 Script: Failed
> 2024-11-14 18:42:58.968 Script: exit
. 2024-11-14 18:42:58.968 Script: Exit code: 1
. 2024-11-14 18:42:58.968 Closing connection.
. 2024-11-14 18:42:58.968 Sending special code: 1
. 2024-11-14 18:42:59.111 Session sent command exit status 0
. 2024-11-14 18:42:59.111 Main session channel closed
. 2024-11-14 18:42:59.111 All channels closed[/quote]

Why would it need to OPEN the file and throw an access error only for that one file? It retrieved several other .csv files from the same location. Seems like it's a terminating error once it hits that file. The file follows a normal naming convention just like the others. Any ideas? Could it be an error with the $transferOptions.AddRawSettings("NewerOnly", "1")?