我试图在C#中使用各种文件函数File.GetLastWriteTime,复制命令放在路径上的文件大于Windows 7上的最大允许路径,即260.它给我一个长路径名错误.在MSDN支持上,他们要求使用\\?\前面的路径.我做了同样的但仍然得到了同样的错误,它似乎没有做任何改变.以下是我的代码.如果我正确使用它或者我需要添加任何东西,请告诉我:
这些我正在使用的所有lib作为代码还有其他东西:
以下是各自的代码:
filesToBeCopied = Directory.GetFiles(path,"*",SearchOption.AllDirectories);
for (int j = 0; j < filesToBeCopied.Length; j++)
{
try
{
String filepath = @"\\?\" + filesToBeCopied[j];
File.GetLastWriteTime(filepath);
}
catch (Exception ex)
{
MessageBox.Show("Error Inside the single file iteration for the path:" +
filesToBeCopied[j] + " . The exception is :" + ex.Message);
}
}
Run Code Online (Sandbox Code Playgroud)
其中path是Windows机器上以驱动器号开头的文件夹的路径.例如:d:\abc\bcd\cd\cdc\dc\..........
c# ×1