c# - Can Directory.CreateDirectory make a folder accessible from one thread but not others? -


we have list of complete paths want copy files to, sort of this

 c:\temp\sub1\file1a  c:\temp\sub1\file1b  c:\temp\sub2\file2a  c:\temp\sub3\file3a  c:\temp\sub3\file3b  c:\temp\sub3\file3c  etc.... 

there code this

for each file in file list     if (!directory.exists(dirname)     {         directory.createdirectory(dirname)     } 

and can see logs sub folders created, , 1 attempt made each sub folder - directory.exists returning true after first file in each sub folder has been through above loop.

then code like

var filedownloadactions = new list<action>();  // populated list  getfile(requiredinfo)  parallel.invoke(new paralleloptions {maxdegreeofparallelism = 10},                 filedownloadactions.toarray()); 

and here odd bit - of time works fine, fails multiple directorynotfoundexceptions - claiming can't find directories have been created!

sometime can't find of created sub folders, works not others.

current working theory although thread created folders thinks created (and checks directory.exists returning true no matter how many files have in folder try create each folder once) haven't been created on os , when try access them other threads goes bang!

ever seen / heard of before?

is our working theory correct , if best way fix this? (i'd rather not put in sleep!)

could explained access modified closure?

i guess depends on loop looks like, i've seen if you're storing delegates execution later there possibility you're not getting dirname value may expecting.

have @ http://www.yoda.arachsys.com/csharp/csharp2/delegates.html under captured variables section.


Comments

Popular posts from this blog

Why does Ruby on Rails generate add a blank line to the end of a file? -

keyboard - Smiles and long press feature in Android -

node.js - Bad Request - node js ajax post -