Why does Directory.CreateDirectory throw a DirectoryNotFoundException when attempting to create the following path?
"c:\\temp\\aips\\data\\prn"
with message indicating it could not find a part of the path "c:\"
.
Yet, if passed the following path "c:\\temp\\aips\\data\\power"
, it returns successfully.
The paths are copied directly from the Visual Studio debugger hence the back slash delimiters.
On my system, the folder c:\temp\aips\data
already exists.
This will happen when TFS has some changes staged that no longer exist on the file system. For instance, if you add some files in Visual Studio (which adds them to the changes list), delete them directly from the file system, then attempt to check in the changes, it will complain that it could not find the file(s).
The error you have is mainly caused when you're trying to check in files which is no longer exist on the machine. To resolve it, go to Source Control Explorer -> select these missing files -> Undo Pending Changes. Or you can just left these files in the Excluded Changes list to not checking them.
If the error message says that it couldn't find part of the path then it couldn't find part of the path. You cannot create a folder and a file at the same time. You can only create a file in a folder that already exists. If the folder doesn't exist then you must create it first, then create the file.
As Scott Chamberlain says in a comment prn
is one of the reserved device names and it points to the print device in DOS.
so change your path to another name and don't use the following reserved names for the name of a file:
CON, PRN, AUX, NUL, COM1, COM2, COM3, COM4, COM5, COM6, COM7, COM8, COM9, LPT1, LPT2, LPT3, LPT4, LPT5, LPT6, LPT7, LPT8, and LPT9
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With