I have to prepare an app that drills in a specific drive, reads all the file names and invalidates the underscores SharePoint replaces the characters I am mentioning as illegal characters: ~ #% & amp; * {} / \ | : & Lt; & Gt; ? - ""
How does a link or code provide code, how does it provide? I am very new to C # and need all the help that I can possibly get. I have researched the code on repeated drilling through a drive, but I'm not sure how to replace the character and recursive poisoning together!
Here is the advice to remove invalid characters:
You have to change your set characters to set.
If you have thought about how to recover folders, you can get all the files in these files. With each folder:
var files = System.IO.Directory.EnumerateFiles (currentPath);
and then
foreach (string file in files) {System.IO.File.Move (file, convert filename (file)); }
The Convert file name method will write to accept you as a filename as a string, and return a filename stripped from the bad characters.
Note, if you are using .NET 3.5, GetFiles ()
also works according to MSDN:
Energet file and GetFiles methods are different: when you use enumerate files, you can enumerate the collection of names before the entire collection; When you use GetFiles, you will have to wait for the full name to be returned to you before you reach the array. Therefore, when you are working with many files and directories, EnumerateFiles can be more efficient.
How to continuously index directories
string path = "c: \ dev"; string Search Pattern = "*. * "; [String] [dirNameArray = Directory.GetDirectories (path, searchPattern, SearchOption.AllDirectories); // or, for better performance: // (but if you do not have access to the subdirectory, then the second link below See) IEnumerable & lt; string & gt; DirNameEnumeration = Directory.Incredited Directory (Path, Search Pattern, Searchoption.All Directories);
Comments
Post a Comment