Directory.GetDirectories stalls on Remote Share

The name of the pictureThe name of the pictureThe name of the pictureClash Royale CLAN TAG#URR8PPP


Directory.GetDirectories stalls on Remote Share



I am using the NetworkShareAccessor found here. I cannot list folders or files. This is my code:


using (NetworkShareAccessor.Access(serverAddress, domain, username, password))
{
directories = Directory.GetDirectories(folderPath, "*", SearchOption.AllDirectories);
}



I use the same using statement to copy files to and from the share and that works fine.


using



When I debug, the using statement works, the share is connected, but when I step to directories = (...) the debugger stops on that line.


using


directories = (...)



Nothing happens other than this message from Visual Studio after a minute:



Managed Debugging Assistant 'ContextSwitchDeadlock' Message=Managed
Debugging Assistant 'ContextSwitchDeadlock' : 'The CLR has been unable
to transition from COM context 0xe60638 to COM context 0xe606f0 for 60
seconds. The thread that owns the destination context/apartment is
most likely either doing a non pumping wait or processing a very long
running operation without pumping Windows messages. This situation
generally has a negative performance impact and may even lead to the
application becoming non responsive or memory usage accumulating
continually over time. To avoid this problem, all single threaded
apartment (STA) threads should use pumping wait primitives (such as
CoWaitForMultipleHandles) and routinely pump messages during long
running operations.'



Writing files to the share works fine. Deleting files from the share works. Listing folders or files doesn't. Why? And how do I get around this?



(Thank you to GameScripting for the NetworkShareAccessor code)



EDIT:



It does seem to be a permission issue after all. The code works on other domains and on non-domain computers (e.g. NAS or Linux server).





Works fine for me. Are you sure you are passing the fully qualified folder path there? i.e. UncServername + "" + local folder path?
– LocEngineer
2 days ago





@LocEngineer yes, I am. I can copy to the share and create a folder. But when I try to see which folders are already there or which files, it hangs.
– ToshiBoy
2 days ago





Sounds like the account has no permission for listing folder contents. :-?
– LocEngineer
2 days ago





@LocEngineer. Yes, it's starting to look a lot like that. I have tested this on another domain and it works. I've also tested it on a local NAS and it works.
– ToshiBoy
8 mins ago









By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

Popular posts from this blog

Makefile test if variable is not empty

Will Oldham

Visual Studio Code: How to configure includePath for better IntelliSense results