相关疑难解决方法(0)

C#文件路径重用

我正在尝试在C#中编写一个静态成员函数,或者在.NET Framework中找到一个可以重写文件系统指定文件路径的函数.

例:

string filepath = @"C:\temp.txt";
filepath = FileUtility.RecaseFilepath(filepath);

// filepath = C:\Temp.TXT
// Where the real fully qualified filepath in the NTFS volume is C:\Temp.TXT
Run Code Online (Sandbox Code Playgroud)

我已经尝试了下面的代码和它的许多变体,它仍然无法正常工作.我知道Windows一般不区分大小写但我需要将这些文件路径传递给ClearCase,后者考虑文件路径大小写,因为它是Unix和Windows应用程序.

public static string GetProperFilePathCapitalization(string filepath)
{
    string result = "";

    try
    {
        result = Path.GetFullPath(filepath);
        DirectoryInfo dir = new DirectoryInfo(Path.GetDirectoryName(result));
        FileInfo[] fi = dir.GetFiles(Path.GetFileName(result));
        if (fi.Length > 0)
        {
            result = fi[0].FullName;
        }
    }
    catch (Exception)
    {
        result = filepath;
    }

    return result;
}
Run Code Online (Sandbox Code Playgroud)

.net c# filenames case-sensitive filepath

21
推荐指数
1
解决办法
8991
查看次数

区分大小写的Directory.Exists/File.Exists

有没有办法让案件敏感Directory.Exists/ File.Exists从那以后

Directory.Exists(folderPath)
Run Code Online (Sandbox Code Playgroud)

Directory.Exists(folderPath.ToLower())
Run Code Online (Sandbox Code Playgroud)

都回归true

大多数时候它并不重要但我使用的宏如果路径与100%的情况不匹配似乎不起作用.

c# directory file case-sensitive file-exists

11
推荐指数
1
解决办法
1万
查看次数

如何在Windows上的Node.js中获取文件的大小写确切路径?

我有一条路径,让我们说C:\temp\something.js,我想在Windows上获得路径的大小写确切版本 - 所以如果C:\Temp\someThing.js存储在磁盘上,我想得到这个值(路径).

如何从Node.js中的后一个路径获取前一个路径?

我已经通过FS API(去https://nodejs.org/api/fs.html),我还没有发现任何有用的东西(即fs.realpathSync,fs.statSync,fs.accessSync没有回我的需要).

windows macos path case-sensitive node.js

10
推荐指数
2
解决办法
2293
查看次数