using System; using System.IO; public class AFile { public static string CheckFOURCC(FileStream fs, ref long bytesRead) { var buffer = AAssit.ReadByArray(fs, ref bytesRead, 4, 0); string FOURCC = System.Text.Encoding.ASCII.GetString(buffer); Console.WriteLine($"File {fs.Name} FOURCC: {FOURCC}"); if (FOURCC != "MOXB" && FOURCC != "MOXT") { // not a valid FOURCC. No need to read it. bytesRead = 0; } return FOURCC; } public static string NormalizePath(string path, bool bundlePath = false) { if (string.IsNullOrEmpty(path)) return path; // Remove invalid characters from the path char[] invalidChars = Path.GetInvalidPathChars(); foreach (char c in invalidChars) { path = path.Replace(c.ToString(), string.Empty); } // Additional handling for other potentially problematic characters // that might not be included in GetInvalidPathChars but can cause issues // path = path.Replace(":", string.Empty) // .Replace("*", string.Empty) // .Replace("?", string.Empty) // .Replace("\"", string.Empty) // .Replace("<", string.Empty) // .Replace(">", string.Empty) // .Replace("|", string.Empty); path = path.Trim(); var items = path.Split('\\'); // use Path.Combine to normalize the path path = Path.Combine(items); // #if it's a bundle path. It always use / as separator if (bundlePath) { path = path.Replace("\\", "/"); } return path; } }