Well my reasoning was that if i create it upfront and then something down the line goes bad, I've now left over this directory (incomplete work).
Plus as Ann said Directory.CreateDirectory creates all levels (subdirectories) in the path so i wouldn't know how to clean this up. On Thu, Jun 17, 2010 at 2:14 PM, Corneliu I. Tusnea <[email protected]>wrote: > Why not create the folder upfront? > > Corneliu > > > > > On Thu, Jun 17, 2010 at 2:12 PM, Tom Rutter <[email protected]> wrote: > >> Mainly because of design I guess. I have a function that uses the folder >> path way down the line someplace after a lot of other work has been done, so >> i dont want to do lots of stuff and then find out the folder path i was >> given cant be used now. To avoid this overhead i would like to check it up >> front. >> >> On Thu, Jun 17, 2010 at 2:07 PM, Michael Minutillo < >> [email protected]> wrote: >> >>> Hi Tom, >>> >>> Any extra context you can give us as to why you might want to do this? Is >>> it something you could use http://transactionalfilemgr.codeplex.com/ >>> for? >>> >>> Regards, >>> Mike >>> >>> >>> On Thu, Jun 17, 2010 at 11:59 AM, Tom Rutter <[email protected]>wrote: >>> >>>> Hi Ann, yes but I don't want to actually create it. i just want to check >>>> if it *can* be created. >>>> >>>> >>>> On Thu, Jun 17, 2010 at 1:56 PM, Anne Busby <[email protected]>wrote: >>>> >>>>> Directory.CreateDirectory Method (String) >>>>> Any and all directories specified in path are created, unless they >>>>> already exist or unless some part of path is invalid. The pathparameter >>>>> specifies a directory path, not a file path. If the directory >>>>> already exists, this method does nothing. >>>>> >>>>> >>>>> *Anne Busby ** **|** **Senior Developer** * >>>>> >>>>> *3 Sarich Way, Technology Park, Bentley,* *WA** 6102 >>>>> Phone +61 8 6250 7900** |** Fax +61 8 6250 7999* >>>>> >>>>> P Please consider the environment before you print this email >>>>> ------------------------------ >>>>> *From:* [email protected] [[email protected]] >>>>> On Behalf Of Tom Rutter [[email protected]] >>>>> *Sent:* Thursday, 17 June 2010 11:51 AM >>>>> *To:* ozDotNet >>>>> *Subject:* How to validate directory path >>>>> >>>>> Gday .net gurus >>>>> >>>>> Can I please get some recommendations on how to check if a directory >>>>> can be created given a path if it already doesnt exist? >>>>> As an example something like this >>>>> >>>>> public static bool CanCreateDir(string path) { >>>>> if (System.IO.Directory.Exists(path)) { >>>>> return true; >>>>> } >>>>> >>>>> //TODO - figure out if the directory can be created >>>>> } >>>>> >>>>> Cheers, >>>>> Tom >>>>> >>>> >>>> >>> >>> >>> -- >>> Michael M. Minutillo >>> Indiscriminate Information Sponge >>> Blog: http://wolfbyte-net.blogspot.com >>> >> >> >
