Can you change the workflow so that the folder creation happens closer to
crunch-time? This does not solve your problem but may not annoy the user as
much, particularly if you provide a method of recovery if permissions aren't
correct.

This stackoverflow discussion links to checking permissions and comments on
why it's probably too hard :-(

<
http://stackoverflow.com/questions/130617/how-do-you-check-for-permissions-to-write-to-a-directory-or-file/462329#462329
>

It also may explain why Greg was being lied to when he tried checking
permissions.

Michael's comment on transactions might offer you another path but, as I
understand it, file system transactions are OS version dependent.

-- 
Regards,
noonie

On 18 June 2010 10:01, Tom Rutter <[email protected]> wrote:

> The time in fact can vary. Some times it can be a few seconds and other
> times it may be 10s of minutes. I would hate it as a user if i make a
> request and then 5 minutes later i get told that  the directory path i
> provided as input is bad. I prefer to get told that up front
>
>
> On Fri, Jun 18, 2010 at 8:33 AM, noonie <[email protected]> wrote:
>
>> Greetings,
>>
>> On 17 June 2010 14:12, 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.
>>
>>
>> How far down? 300 clock cycles 3,000? Does it really matter that much in
>> real-time?
>>
>> Will you have a lot of cleaning up to do later on or will recovering from
>> a permissions exception be too difficult?
>>
>>
>>> To avoid this overhead i would like to check it up front.
>>
>>
>> If the real-time lag is just milliseconds then there's not much point but
>> if it is a considerable time then, as has been said before in this thread,
>> circumstances may have changed betwixt check and do.
>>
>> Sometimes it easy to look at all your lines of code and come to the belief
>> that there's "a lot of work" going on in there when the reality is that it
>> actually happens faster than an eye-blink.
>>
>> --
>> Regards,
>> noonie
>>
>>
>>>  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
>>>>
>>>
>>>
>>
>

Reply via email to