help with excluding subfolder in C#

Advertisement

andybruner
Joined:
Posts:
7

help with excluding subfolder in C#

Sorry to bother you but I'm having a terrible time trying to exclude a subfolder.

my directory structure looks like this. /parcs/download/PNB/Processed
I have an xml file in /parcs/download/PNB that I am moving to a local server. That works fine. However, my code is also finding the /Processed folder and transferring those files as well. How do I make it so that it only gets the files in /parcs/download/PNB and excludes /Processed?
TransferOptions transferOptions = new TransferOptions();
transferOptions.TransferMode = TransferMode.Binary;
transferOptions.FileMask = "*/"; 
 
TransferOperationResult transferResult;
transferResult =
  session.GetFilesToDirectory("/parcs/download/PNB/", mApplicationDataPath,"*/",false, transferOptions);

Reply with quote

Advertisement

Guest

Re: help with excluding subfolder in C#

This does not work. GetFilesToDirectory requires another argument for filemask within it that you did not show. If I include it I get an error.
session.GetFilesToDirectory(
    "/parcs/download/PNB/", mApplicationDataPath, "|*/", false,
    transferOptions);
I tried just using
transferResult = session.GetFiles(
  "/parcs/download/PNB/", mApplicationDataPath, options: transferOptions);
but this did not work either.

Reply with quote

andybruner
Joined:
Posts:
7

Hi Martin,
Just want to make sure this is still on your radar. I still would really appreciate your help on this one. Can you just layout in very straightforward code what I need to do to use GetFilesToDirectory to exclude subfolders? As I mentioned earlier, GetFilesToDirectly asks for a filemask as a parameter but it also include transferoptions. It is not like PutFiles where PutFiles does not include filemask as a parameter. I have tried different combinations and nothing works.
session.GetFilesToDirectory(
    "/parcs/download/PNB/", mApplicationDataPath,"|*/", false,
    transferOptions);

Reply with quote

andybruner
Joined:
Posts:
7

I finally succeeded.
session.GetFilesToDirectory(
    "/parcs/download/PNB/", mApplicationDataPath, null,
    options: transferOptions);

Reply with quote

Advertisement

Advertisement

You can post new topics in this forum