MSBuild Concat task only deals with ASCII files?

Well I got around it by writing a utility C# class. It is not designed to handle exceptions, they are handled by the calling class or unhandled in the console.

Well I got around it by writing a utility C# class. It is not designed to handle exceptions, they are handled by the calling class or unhandled in the console. It converts the files to ASCII, removes any invalid characters and rewrites the files.

I spent a while wondering why I was getting access-denied issues, make sure you have all the files you want to convert checked out before you convert them! Here it is if you are interested: using System; using System. IO; using System.

Text; /// /// Manages encoding of text files. /// public class TextFileEncoding { /// /// Main command-line entry. /// /// public static void Main(string args) { if (args.

Length > 0) { string argParam = args0.ToString().Trim().ToLower(); switch (argParam) { // Return encoding for a file. Case "get": Encoding enc = GetEncoding(args1.ToString()); Console. WriteLine(enc.

EncodingName); break; // convert encoding for a path with a given pattern to ASCII. Case "toascii": int count = ConvertToAscii(args1.ToString(), args. Length == 3?

Args2 : "*. *"); Console. WriteLine("Successfully converted " + count + " files."); break; default: Console.

WriteLine("Invalid parameter. Expected get or toascii"); break; } } else { Console. WriteLine("Missing filename parameter.

\nFormat: TextFileEncoding. Exe get|toascii "); } } /// /// Returns the encoding of the filename at the specified path. /// /// /// public static Encoding GetEncoding(string filename) { StreamReader fileStream = new StreamReader(filename, true); return GetEncoding(fileStream); } /// /// Returns the encoding of the file stream.

/// /// /// public static Encoding GetEncoding(StreamReader fileStream) { return fileStream. CurrentEncoding; } /// /// Converts all files to ascii encoding. /// /// /// public static int ConvertToAscii(string path, string pattern) { DirectoryInfo pathInfo = new DirectoryInfo(path); int count = 0; // Get files in directory, recursively.

FileInfo files = pathInfo. GetFiles(pattern, SearchOption. AllDirectories); foreach (FileInfo file in files) { // Encode to ASCII.

If (EncodeAscii(file)) { count++; } } return count; } /// /// Converts file to ascii. /// /// /// private static bool EncodeAscii(FileInfo file) { ASCIIEncoding encoder = new ASCIIEncoding(); // Get content of file as string. String content = File.

ReadAllText(file. FullName); // Convert to an ASCII byte array. Byte asciiString = encoder.

GetBytes(content); // Convert to string, so all unknown characters get removed. String cleanString = encoder. GetString(asciiString); // Convert back to byte array for writing to file.

Byte cleanBytes = encoder. GetBytes(cleanString); // Delete and rewrite file as ASCII.File.Delete(); File. WriteAllBytes(file.

FullName, cleanBytes); return true; } }.

I cant really gove you an answer,but what I can give you is a way to a solution, that is you have to find the anglde that you relate to or peaks your interest. A good paper is one that people get drawn into because it reaches them ln some way.As for me WW11 to me, I think of the holocaust and the effect it had on the survivors, their families and those who stood by and did nothing until it was too late.

Related Questions