cancel
Showing results for 
Search instead for 
Did you mean: 

Create Directory code

JoachimGeelen
Level 3
Hi all, From the VBO we have use a Create Directory BO. This uses the following code ----- Try If Not Directory.Exists(Directory_Path) Then Directory.CreateDirectory(Directory_Path) Else If ErrorIfAlreadyExists Then Throw New ApplicationException("Directory already exists") End If Success = True Catch Ex as Exception Success = False Error_Message = Ex.ToString() End Try ---- We have two questions about this code: - It doesn't seem to create a new directory - How can we set a name (from a data file) as name of the directory? Thanks for helping!
3 REPLIES 3

John__Carter
Staff
Staff
The code will attempt to create a directory using the path you provide as an input. Assuming the path is valid, the directory does not already exist, and the Windows user has permission to create a directory, then the code should work. If it does not, an error message is provided as an output.

GopalBhaire
Level 10
path = @""path""+dataitem; // your data item should be input try{ if (System.IO.Directory.Exists(path)) { checkPath=true; } else { System.IO.DirectoryInfo di = System.IO.Directory.CreateDirectory(path); checkPath=false; } } catch (Exception e) { throw e; } This is C# code I use to Create and/or check folder You need to have permissions to

JoachimGeelen
Level 3
Thanks! It's working with the last code.