While performing certain task in a console application, i am unable to separate normal folder and hidden ones such as "Forms","FormServerTemplates" etc. I am using SPFolder in the obejct model. I have tried both FolderObject.property.count=21 and FolderObject.item==null, but none of these seems to filter the hidden folders.
Scenario : To copy all folders and files inside root folder of document library. Excluding hidden folders such as "Forms", "FormServerTemplates" etc.
static void traverseFolder(SPFolder fold, string path)
{
try
{
if (!(fold.Item==null))
{
var Listdir = path + @"\" + fold.Name.ToString();
string listpath = Listdir.ToString();
if (!Directory.Exists(Listdir))
Directory.CreateDirectory(Listdir);
foreach (SPFolder subFold in fold.SubFolders)
{
if (!(subFold.Item==null))
traverseFolder(subFold, listpath);
}
foreach (SPFile file in fold.Files)
{
byte[] binFile = file.OpenBinary();
System.IO.FileStream fstream =
System.IO.File.Create(listpath + "\\" + file.Name);
fstream.Write(binFile, 0, binFile.Length);
//Console.WriteLine(file.Name);
}
} //Console.WriteLine(item.File.Name);
}
catch (Exception ex)
{
EventLog myException = new EventLog("");
myException.Source = "SiteCol File Copy Exception";
myException.WriteEntry("Error in copying " + ex.Message,EventLogEntryType.Error);
}
}
Is there any other way to separate?
Thanks