I have a shared folder @"\Machine Name\Venkatesh\test" and which contains a file name.
and I want to copy that file into C:\temp\Mani\1.pdf.
I tried the following C# Code but it throws an Exception,
string sourcepath = @"\\Venki\Venkatesh\test";
string destFileName = @"C:\temp\Mani\1.pdf";
try
{
string[] files = Directory.GetFiles(sourcepath);
foreach (string file in files)
{
Console.WriteLine(file.Length);
File.Copy(file, destFileName);
Console.WriteLine("Success");
Console.WriteLine("Done");
}
}
catch (Exception ex)
{
throw (ex);
}
The specified path, file name, or both are too long. The fully qualified file name must be less than 260 characters, and the directory name must be less than 248 characters. Kindly help me with this.
Thanks in advance.