Moving files in .NET C# invalid characters
Posted on 2010-11-16
I have a loop that compares a filename in my database to a folder of files that should match the filenames. When I do this line to move the files out of their folder and into a destination directory, it doesn't get all of the files moved. I suspect it's because of some invalid characters. I replaced the single quote. What others should I be looking for? And/or what's the best way to account for any filename.
Do I need to check for backslashed too? Or does the @ take care of that?
strSourceFile = row["Filename"].ToString().Replace("'", "''");
File.Move(@"C:\SHAT_TRACKS\" + strSourceFile, strDestPath + @"\" + strSourceFile);