Creating a directory on a shared drive

tempus

Member
Joined
Oct 8, 2013
Messages
11
Programming Experience
10+
I have a shared drive mapped to my local as drive Z. Using Windows Explorer, I can create directories in that folder all day long. The moment I try to add a directory from anywhere else, I get an error - A device attached to the system is not functioning. I'd ideally like to create the new directory from C# - which throws an IO exception with the same message. I've tried xcopy and robocopy and both of those also fail with the same error.

So, does anyone know why creating a folder would work 100% of the time in explorer and 0% from anywhere else (including the most needed C# code)?

I've tried both of these to no avail

C#:
[COLOR=#000000]var di [/COLOR][COLOR=#666600]=[/COLOR][COLOR=#000088]new[/COLOR]DirectoryInfo[COLOR=#666600]([/COLOR][COLOR=#008800]"[/COLOR][COLOR=#000000]z[/COLOR][COLOR=#666600]:[/COLOR][COLOR=#000000]\"[/COLOR][COLOR=#666600]);[/COLOR][COLOR=#000000]
di[/COLOR][COLOR=#666600].[/COLOR]CreateSubDirectory[COLOR=#666600]([/COLOR][COLOR=#008800]"Test"[/COLOR][COLOR=#666600]);[/COLOR][COLOR=#000000]


var di [/COLOR][COLOR=#666600]=[/COLOR][COLOR=#000088]new[/COLOR]DirectoryInfo[COLOR=#666600]([/COLOR][COLOR=#008800]"[/COLOR][COLOR=#000000]\\servername\sharename\attachments\"[/COLOR][COLOR=#666600]);[/COLOR][COLOR=#000000]
di[/COLOR][COLOR=#666600].[/COLOR]CreateSubDirectory[COLOR=#666600]([/COLOR][COLOR=#008800]"Test"[/COLOR][COLOR=#666600]);[/COLOR]

I've also tried (where test is the folder I'd like created)

C#:
xcopy file.txt z:\test\file.txt /T 
robocopy c:\ z:\test\ file.txt /COPY:DT

I've also done this with no happiness... Same error

C#:
[COLOR=#000000]c:\> z:
z:\> md test[/COLOR]

If I navigate to either the Z drive or the share directly in Windows Explorer, I can right click and add a folder (and rename it). I'm stumped. I keep thinking its a permissions issue of some kind but then rationalize that Explorer and a command prompt are both running as my user (non-elevated) so how can permissions come into play..

Any one have any ideas?
 
If you can't do this from Windows either then this is not a C# issue. This sounds like a Windows configuration issue. Once you can get those other tools to work, it seems logical that the C# code you have will work too.
 
Yeah, I know its not really a C# issue. I'm just completely out of answers and was hoping someone else had seen an issue like this. Thanks
 
Is there security software that could be blocking access? Generally when Explorer have access so does any other software.

Also, make sure the share is "active", if Explorer shows the share with a red x activate it first by opening it with Explorer - although I think if this was the case you should get a "path not exists" error.
 
Yeah, I know its not really a C# issue.

Will you post questions about knitting here next? This site is dedicated to C# development specifically. The fact that C# developers may know something about Windows configuration does not mean that this site is the place to discuss such topics. There are other places that are dedicated to topics like that and it's probably just as inappropriate to post questions about C# development there.
 
JohnH, thanks for being more open minded regarding my question and attempting to offer assistance.

jmcilhinney, I'm working on a C# project, writing C# code and while there is clearly something outside of the actual language at play here, I have always read these forums as a place (as a coder) to get help. I'm not the first dev to have to write files or create directories and assumed (I guess incorrectly) that other developers may have stumbled upon the same issue at some point in time. Just close the thread and I'll take my question elsewhere.
 
Back
Top Bottom