Post a reply

Before posting, please read how to report bug or request support effectively.

Bug reports without an attached log file are usually useless.

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

martin

Re: using .NetAssembly to remove folder

Because that's not a valid PowerShell code. It looks more like C#, but it's not valid C# either.
Also with Session.RemoveFile, do not use RemotePath.EscapeFileMask.

It should be like:
$session.RemoveFile("/folder/$timestamp")

(assuming you have $session variable with an instance of Session class)
ramc10

Using .NET assembly to remove folder

Hi,
I have an SFTP site were files are delivered in a folder, were the folder name would be the previous day date. If it's 8th October the folder would be 20201007. After that the files are downloaded, I need to remove the folder with all of its contents.

I configured the below variables in the script
$yesterday = (Get-date).AddDays(-1)
$timestamp = $yesterday.ToString("yyyyMMdd")

Then I'm trying to remove the folder using the below command
Session.RemoveFile(RemotePath.EscapeFileMask(/folder/$timestamp))

I'm being prompted /folder/$timestamp isn't recognized.

Regards
RamC