I'm currently using the .Net Framework and the C# for a project.
I would like to know how to remove the 260 characters limit of the path.
I've tried to go to the regedit ans the gpedit but nothing worked. I've tried to put the "\?" prefix but the path was unrecongnised.
Here a sample of the C# code :
private static void DirectoryCopy(string sourceDirName, string destDirName, bool copySubDirs)
{
// Get the subdirectories for the specified directory.
DirectoryInfo dir = new DirectoryInfo(sourceDirName);
if (!dir.Exists)
{
throw new DirectoryNotFoundException(
"Le répertoire source n'existe pas ou n'est pas accessible : "
+ sourceDirName);
}
DirectoryInfo[] dirs = dir.GetDirectories();
// If the destination directory doesn't exist, create it.
if (!Directory.Exists(destDirName))
{
Directory.CreateDirectory(destDirName);
}
// Get the files in the directory and copy them to the new location.
FileInfo[] files = dir.GetFiles();
foreach (FileInfo file in files)
{
temppath = Path.Combine(destDirName, file.Name);
try
{
file.CopyTo(temppath, false);
}
catch (Exception ex)
{
Erreurs.Add(ex.Message);
Erreurs.Add(temppath);
}
}
// If copying subdirectories, copy them and their contents to new location.
if (copySubDirs)
{
/*Utility.NetworkDrive.MapNetworkDrive("R", @"\\unc\path");
var dirs1 = Directory.GetDirectories("R:");
Utility.NetworkDrive.DisconnectNetworkDrive("R", true);*/
foreach (DirectoryInfo subdir in dirs)
{
temppath = Path.Combine(destDirName, subdir.Name);
// string fullpath = @"\\?\" + subdir.FullName; -- HERE'S WHAT I'VE TRIED
try
{
string sousdoss = subdir.FullName;
string loclogic = Application.StartupPath + @"\Xcopy.bat";
System.Diagnostics.Process proc = new System.Diagnostics.Process();
proc.StartInfo.FileName = Application.StartupPath + @"\Xcopy.bat";
proc.StartInfo.Arguments = String.Format("{0} {1} {2}",loclogic, sousdoss, temppath);
//set the rest of the process settings
proc.Start();
}
catch(Exception ex)
{
Erreurs.Add(ex.Message);
}
}
}
}
And here's my batch code (I would like to pass 'loclogic' and 'sousdoss' to %1 and %2) :
xcopy "%1" "%2" /c /h /e /r /y /s
Thanks for your help !