fork download
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Text;
  4. using System.IO;
  5.  
  6. namespace ConsoleApplication2
  7. {
  8. class Program
  9. {
  10. static void Main(string[] args)
  11. {
  12. string text;
  13. List<byte> data = new List<byte>();
  14. try
  15. {
  16. string filename = Path.GetFileNameWithoutExtension(args[0]);
  17. string dirname = Path.GetDirectoryName(args[0]);
  18. using (StreamReader sr = new StreamReader(
  19. args[0], Encoding.GetEncoding("Shift_JIS")))
  20. {
  21. text = sr.ReadToEnd();
  22. }
  23.  
  24. text = text.Replace(" ", "").Replace("\r", "").Replace("\n", "");
  25. for (int i = 0; i < text.Length - 1; i = i + 2)
  26. {
  27. string buf = text.Substring(i, 2);
  28. data.Add(Convert.ToByte(buf, 16));
  29. }
  30.  
  31. byte[] bytesData = data.ToArray();
  32.  
  33. using (FileStream fs = new FileStream(dirname + @"\" + filename + @".rar",
  34. FileMode.Create, FileAccess.Write))
  35. {
  36. byte[] bs = new byte[fs.Length];
  37. fs.Write(bytesData, 0, bytesData.Length);
  38. }
  39. }
  40. catch (Exception e)
  41. {
  42. Console.WriteLine(e.Message);
  43. }
  44. }
  45. }
  46. }
Success #stdin #stdout 0.04s 36936KB
stdin
Standard input is empty
stdout
Array index is out of range.