Discussion:
Directory Ops Behaving Asynchronous
Brady Kelly
2008-05-19 17:42:33 UTC
Permalink
Ryan Heath
2008-05-19 19:54:56 UTC
Permalink
I cannot speak for Dir.Del but another thing to consider: Are there
other threads/progs deleting/creating that dir?

// Ryan

2008/5/19, Brady Kelly <***@chasesoftware.co.za>:
> I have the following code execute:
>
>
>
> if (Directory.Exists(exportFolder))
>
> {
>
> Directory.Delete(exportFolder, true);
>
> }
>
> Directory.CreateDirectory(exportFolder);
>
>
>
> and then a database update, and then:
>
>
>
> wiz57.PerformExport();
>
>
>
> Occassionally, about 1 in 20 tests I run in the IDE, PerformExport fails
> because exportFolder does not exist. How can it not exist if I create it and
> no exception is thrown? I can only suspect that the Directory code is not
> truly synchronous, and has not completed before PerformExport executes.
>
>
>
> Brady Kelly
> Software Developer
>
> Chase Software
> Office: 011 287 1820
> Cell: 078 331 3781
> Fax: 086 691 5653
>
> <http://www.chasesoftware.co.za/> www.ChaseSoftware.co.za
>
>
>
>
> ===================================
> This list is hosted by DevelopMentor(R) http://www.develop.com
>
> View archives and manage your subscription(s) at http://discuss.develop.com
>

===================================
This list is hosted by DevelopMentor® http://www.develop.com

View archives and manage your subscription(s) at http://discuss.develop.com
Brady Kelly
2008-05-20 08:28:28 UTC
Permalink
Brady Kelly
2008-06-05 11:52:37 UTC
Permalink
Ryan Rinaldi (TT)
2008-05-19 19:56:35 UTC
Permalink
Brady Kelly
2008-05-20 08:29:06 UTC
Permalink
Greg Young
2008-05-20 15:24:40 UTC
Permalink
I am unable to duplicate your issue ... Are you using a local or a
network drive? Can you provide your test application so I can look
through it?

Cheers,

Greg

On Tue, May 20, 2008 at 1:29 AM, Brady Kelly <***@chasesoftware.co.za> wrote:
> None, I'm just running a test C# console application.
>
>> -----Original Message-----
>> From: Discussion of development on the .NET platform using any managed
>> language [mailto:DOTNET-***@DISCUSS.DEVELOP.COM] On Behalf Of Ryan
>> Rinaldi (TT)
>> Sent: 19 May 2008 09:57 PM
>> To: DOTNET-***@DISCUSS.DEVELOP.COM
>> Subject: Re: [DOTNET-CLR] Directory Ops Behaving Asynchronous
>>
>> What test framework are you using?
>>
>> -----Original Message-----
>> From: Discussion of development on the .NET platform using any managed
>> language [mailto:DOTNET-***@DISCUSS.DEVELOP.COM] On Behalf Of Brady
>> Kelly
>> Sent: Monday, May 19, 2008 12:43 PM
>> To: DOTNET-***@DISCUSS.DEVELOP.COM
>> Subject: [DOTNET-CLR] Directory Ops Behaving Asynchronous
>>
>> I have the following code execute:
>>
>>
>>
>> if (Directory.Exists(exportFolder))
>>
>> {
>>
>> Directory.Delete(exportFolder, true);
>>
>> }
>>
>> Directory.CreateDirectory(exportFolder);
>>
>>
>>
>> and then a database update, and then:
>>
>>
>>
>> wiz57.PerformExport();
>>
>>
>>
>> Occassionally, about 1 in 20 tests I run in the IDE, PerformExport
>> fails
>> because exportFolder does not exist. How can it not exist if I create
>> it
>> and
>> no exception is thrown? I can only suspect that the Directory code is
>> not
>> truly synchronous, and has not completed before PerformExport executes.
>>
>>
>>
>> Brady Kelly
>> Software Developer
>>
>> Chase Software
>> Office: 011 287 1820
>> Cell: 078 331 3781
>> Fax: 086 691 5653
>>
>> <http://www.chasesoftware.co.za/> www.ChaseSoftware.co.za
>>
>>
>>
>>
>> ===================================
>> This list is hosted by DevelopMentor(r) http://www.develop.com
>>
>> View archives and manage your subscription(s) at
>> http://discuss.develop.com
>>
>> ===================================
>> This list is hosted by DevelopMentor. http://www.develop.com
>>
>> View archives and manage your subscription(s) at
>> http://discuss.develop.com
>
> ===================================
> This list is hosted by DevelopMentor(R) http://www.develop.com
>
> View archives and manage your subscription(s) at http://discuss.develop.com
>



--
We are what we repeatedly do. Excellence, then, is a habit.

===================================
This list is hosted by DevelopMentor® http://www.develop.com

View archives and manage your subscription(s) at http://discuss.develop.com
Brady Kelly
2008-05-20 16:00:54 UTC
Permalink
Peter Ritchie
2008-05-20 16:27:13 UTC
Permalink
I'm unable to reproduce too ,in 10,000 iterations performing the actions
you've described (except the database update). Can you provide the
details of the exception?

Do you have an anti-virus programming running? What happens if you turn
it off?

If there truly is no other threads or processes that are deleting that
directory, I can't think of anything else that could cause that.

Is the directory a sub-directory of a shared directory? I once
encountered someone with mysterious disappearing files because he had
shared the directory and a user on another computer was performing
housekeeping on what they thought was a local drive. But, about 1 in 20
seems a little too regular for that...

===================================
This list is hosted by DevelopMentor® http://www.develop.com

View archives and manage your subscription(s) at http://discuss.develop.com
Brady Kelly
2008-05-20 16:54:08 UTC
Permalink
Fabian Schmied
2008-05-23 16:11:49 UTC
Permalink
I'm seeing the same problem every once in a while when running a high
number of automated tests (NUnit 2.2 or 2.4 in this case) with each
test deleting and re-creating a directory: sometimes, directory
creation fails immediately after the original was deleted. The IO
exception claims that the old directory still exists. Everything is
strictly sequential, no multithreading going on. The directory is a
perfectly ordinary NTFS folder on a local hard drive (with RAID
mirroring). And it happens on different PCs, so it's likely not a
hardware issue.

It's not reproducible at all, so it's hard to find the cause of the
issue (file system, virus scanner, .NET, ...). In fact, we decided to
just work around this issue by running a short while-Directory.Exists
loop after the delete operation, spinning until the directory is
really gone. This "solves" the issue for our test suite, although a
deeper explanation would be nice, of course.

Fabian


On 5/20/08, Peter Ritchie
<***@peterritchie.com> wrote:
> I'm unable to reproduce too ,in 10,000 iterations performing the actions
> you've described (except the database update). Can you provide the
> details of the exception?
>
> Do you have an anti-virus programming running? What happens if you turn
> it off?
>
> If there truly is no other threads or processes that are deleting that
> directory, I can't think of anything else that could cause that.
>
> Is the directory a sub-directory of a shared directory? I once
> encountered someone with mysterious disappearing files because he had
> shared the directory and a user on another computer was performing
> housekeeping on what they thought was a local drive. But, about 1 in 20
> seems a little too regular for that...
>
> ===================================
> This list is hosted by DevelopMentor(R) http://www.develop.com
>
> View archives and manage your subscription(s) at http://discuss.develop.com
>
>

===================================
This list is hosted by DevelopMentor® http://www.develop.com

View archives and manage your subscription(s) at http://discuss.develop.com
Ryan Rinaldi (TT)
2008-05-23 16:41:53 UTC
Permalink
Sebastien Lambla
2008-05-23 17:05:26 UTC
Permalink
Peter Ritchie
2008-05-23 18:06:43 UTC
Permalink
The "delete pending" error occurs if you delete a file or folder but
there's still an active handle for that file or folder somewhere. I'm not
clear whether that only occurs if the handle is in another application
(like virus scanners) or in the same application (the one deleting the
file/folder).

===================================
This list is hosted by DevelopMentor® http://www.develop.com

View archives and manage your subscription(s) at http://discuss.develop.com
Davy J
2008-06-07 15:22:08 UTC
Permalink
Brad,
I hit this a few years ago , if I remember correctly there was no
solution, the only way was to itterate through the files collection
and delete them individually.

hth

Davy J


On Mon, May 19, 2008 at 7:42 PM, Brady Kelly <***@chasesoftware.co.za> wrote:
> I have the following code execute:
> if (Directory.Exists(exportFolder))
> {
> Directory.Delete(exportFolder, true);
> }
> Directory.CreateDirectory(exportFolder);
> and then a database update, and then:
> wiz57.PerformExport();
> Occassionally, about 1 in 20 tests I run in the IDE, PerformExport fails
> because exportFolder does not exist. How can it not exist if I create it and
> no exception is thrown? I can only suspect that the Directory code is not
> truly synchronous, and has not completed before PerformExport executes.
>
>
>
> Brady Kelly
> Software Developer
>

===================================
This list is hosted by DevelopMentor® http://www.develop.com

View archives and manage your subscription(s) at http://discuss.develop.com
Loading...