我敢肯定,在这里我可以忽略一些简单的事情,但是我从来没有遇到过这个问题,也无法找到问题的原因。
这是我的硬盘上的根目录的一个示例:
C:\Folder-1 ( this is a folder )
C:\Folder-2 ( this is a folder )
C:\somename ( this is a file with no extension )
c:\somename.txt ( this is a file with an extension )
我要用于创建新文件夹的代码是这种方法:
static void Main( string[] args )
{
try
{
// try to create a folder in a directory
// where a file with the same name exsists
createDirectory( "c:\somename" );
}
catch
{
// this catches an exception "Cannot create directory, because it already exsist
}
}
private static void createDirectory(string filePath)
{
string directoryPath = Path.GetDirectoryName(filePath);
// if the directory path does not exsists then create it
if (!Directory.Exists(directoryPath))
{
Directory.CreateDirectory(directoryPath );
}
}
有人看到这里有什么问题吗?请帮忙,谢谢!
你不能
您不能有两个名称相同的文件系统条目。
所以:
请注意,NTFS的根源是POSIX,并且POSIX允许多个文件系统条目(因大小写而异),因为文件系统在对象名称方面区分大小写。NTFS继承了此特征,但是Win32会阻止您这样做。因此,使用Win32不可能X
与x
在同一目录中创建的文件一起创建被调用的文件,但是使用较低级别的系统调用是可能的。
有关此主题的更多信息,请参见https://superuser.com/questions/364057/why-is-ntfs-case-sensitive。
但是,不允许,也从未允许多个文件系统条目具有相同的名称。
本文收集自互联网,转载请注明来源。
如有侵权,请联系 [email protected] 删除。
我来说两句