public static void Main(string[] args)
        {
            int blocks = 64;

            int[]  position = new int[blocks];
            int[]  size     = new int[blocks];
            string line;
            string directory = Directory.GetCurrentDirectory();

            Console.WriteLine(directory);
            try
            {
                System.IO.DirectoryInfo di           = new System.IO.DirectoryInfo(@"C:\Users\jgood\Desktop\Relays");
                System.IO.FileInfo[]    SCNfileNames = di.GetFiles("SCN*.txt");
                System.IO.FileInfo[]    fileNames    = di.GetFiles("*.rdb");
                foreach (System.IO.FileInfo fi in fileNames)
                {
                    int optimized = (int)fi.Length;
                    using (FileStream stream = new FileStream(fi.FullName, FileMode.Open, FileAccess.ReadWrite))
                    {
                        byte[] buffer = new byte[optimized];
                        Array.Resize(ref buffer, optimized);
                        stream.Read(buffer, 0, optimized);
                        string rdb = new UTF8Encoding().GetString(buffer);
                        int    n   = blocks - 1;
                        do
                        {
                            position[n] = rdb.LastIndexOf("\u0000\u0000\u0000\u0000\u0000[INFO]", StringComparison.Ordinal) + 7;
                            size[n]     = rdb.Length - position[n];
                            rdb         = rdb.Remove(position[n]);
                            Console.WriteLine(position[n] / 64 + "  " + size[n] / 64);
                            n--;
                        } while (position[n + 1] > 6 && n >= 0);
                        foreach (System.IO.FileInfo SCNfi in SCNfileNames)
                        {
                            using (StreamReader sr = new StreamReader(SCNfi.FullName))
                            {
                                while ((line = sr.ReadLine()) != null)
                                {
                                    string[] words = line.Split(';');
                                    for (int i = 0; i < blocks; i++)
                                    {
                                        if (position[i] > 5)
                                        {
                                            ApplySCN(stream, words, size[i], position[i], buffer);
                                        }
                                    }
                                }
                            }
                        }
                    }
                }
            }
            catch (Exception e)
            {
                Console.WriteLine("Exception: " + e.Message);
            }
        }
Ejemplo n.º 2
0
 public string GetRemoteResourceContent(CombinatorResource resource)
 {
     using (var wc = new WebClient())
     {
         var byteOrderMarkUtf8 = Encoding.UTF8.GetString(Encoding.UTF8.GetPreamble());
         var content           = new UTF8Encoding(false).GetString(wc.DownloadData(resource.AbsoluteUrl));
         if (content.StartsWith(byteOrderMarkUtf8)) // Stripping "?"s from the beginning of css commments "/*"
         {
             content = content.Remove(0, byteOrderMarkUtf8.Length);
         }
         return(content);
     }
 }