Skip to main content

Check if there is a folder in the DM

You can check the folder from DM with the code at the bottom.

public void btnDMKontrol_OnClick(Object sender, EventArgs e)
{
eBAConnection con = CreateServerConnection();
FileSystem fs = con. FileSystem;

string categoryName = "Category1"; // Attachment Category Name
string targetFolder = "Training/" + DateTime.Now.Year.ToString() + "/" + DateTime.Now.Month.ToString("D2");
Try
{
Con. open();
if(!fs. HasFolder(targetFolder + "/" + categoryName))//Check if there is a file or not
{
ShowMessageBox("No folder") ;
}
else //If there is, delete it first and then throw it away
{
ShowMessageBox("Folder exists") ;
}
}
catch (Exception ex)
{
throw new Exception(ex. Message);
}
finally
{
Con. Close();
}
}