I'm trying to read a file to get the path and then search that path.
C:\Users\Public\Documents\ScriptPath.txt contains "C:\Users\Public\Music Folder\"
and here is my code
string ScriptPath = System.IO.File.ReadAllText(@"C:\Users\Public\Documents\ScriptPath.txt");
System.IO.DirectoryInfo dir = new System.IO.DirectoryInfo(ScriptPath);
System.Threading.Thread.Sleep(2000);
foreach (System.IO.FileInfo file in dir.GetFiles("*.*"))
{
MessageBox.Show("{0}, {1}" + file.Name+ file.Length);
}
The Error I get is this.
ArgumentException was unhandled
An unhandled exception of type 'System.ArgumentException' occurred in mscorlib.dll
Additional information: Illegal characters in path.
If anyone could help with understanding why this doesn't work I would be grateful.