Ok, So at my job we do a lot of formats, and to save time I thought I would make a simple c# console app that would copy the users data to a usb or portable hard drive to save us time.
When copying the contents in the pictures folder
string SourcePathPIC = Environment.GetFolderPath(Environment.SpecialFolder.MyPictures);
There are no problems, however when trying to copy the music folders contents, It tells me that it Can't find path
, but when trying the same program on Windows 10, it works.
There is the music part of the Cs file.
//MUSIC
try
{
Console.WriteLine("Downloading Music...");
string SourcePathMUSIC = Environment.GetFolderPath(Environment.SpecialFolder.MyMusic);
string DestinationPathMUSIC = DRIVELOCATION + @"\DOWNLOADEDDATA\music";
foreach (string dirPath in Directory.GetDirectories(SourcePathMUSIC, "*", System.IO.SearchOption.AllDirectories))
{
Directory.CreateDirectory(dirPath.Replace(SourcePathMUSIC, DestinationPathMUSIC));
}
foreach (string newPath in Directory.GetFiles(SourcePathMUSIC, "*.*", System.IO.SearchOption.AllDirectories))
{
File.Copy(newPath, newPath.Replace(SourcePathMUSIC, DestinationPathMUSIC), true);
Console.WriteLine(newPath);
}
Console.WriteLine("------------------------------------------------------------------");
Console.ForegroundColor = ConsoleColor.Green;
Console.WriteLine("Music Downloaded");
Console.ForegroundColor = CONSOLECOLOUR;
Console.WriteLine("------------------------------------------------------------------");
}
catch
{
string SourcePathMUSIC = Environment.GetFolderPath(Environment.SpecialFolder.MyMusic);
string DestinationPathMUSIC = DRIVELOCATION + @"\DOWNLOADEDDATA\music";
foreach (string dirPath in Directory.GetDirectories(SourcePathMUSIC, "*", System.IO.SearchOption.TopDirectoryOnly))
{
Directory.CreateDirectory(dirPath.Replace(SourcePathMUSIC, DestinationPathMUSIC));
}
foreach (string newPath in Directory.GetFiles(SourcePathMUSIC, "*.*", System.IO.SearchOption.TopDirectoryOnly))
{
File.Copy(newPath, newPath.Replace(SourcePathMUSIC, DestinationPathMUSIC), true);
Console.WriteLine(newPath);
}
Console.ForegroundColor = ConsoleColor.Black;
Console.WriteLine("Unable To Copy Some Files, User Has Proctection On Music, You Will Need To Manually Copy The Remaining");
}
Console.ForegroundColor = CONSOLECOLOUR;
Console.WriteLine("------------------------------------------------------------------");
Console.ForegroundColor = CONSOLECOLOUR;
Console.WriteLine(" DOWNLOAD COMPLETE....");
Console.WriteLine("------------------------------------------------------------------");
Console.ReadKey();
}
catch(Exception ex)
{
var CONSOLECOLOR = Console.ForegroundColor;
Console.ForegroundColor = ConsoleColor.Red;
Console.WriteLine("");
Console.WriteLine(ex.Message);
Console.ForegroundColor = CONSOLECOLOR;
//System.Threading.Thread.Sleep(2000);
//Environment.Exit(1);
Console.ReadKey();
}
If you need to see the pictures section, let me know and I can update my question, I didn't add it because i didn't want to add too much code.
Thanks!
OK, I'm posting my answer just in case someone else comes across the same issue I had.
I ended up changing the framework from 3.5 to 4.6.1 compiling and then switching the framework back to 3.5 and hooray, it works!.....WEIRD! since i did't change any code.