Skip to content

Instantly share code, notes, and snippets.

@OrigamiTech
Created January 26, 2011 18:49
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save OrigamiTech/797195 to your computer and use it in GitHub Desktop.
Save OrigamiTech/797195 to your computer and use it in GitHub Desktop.
Not every byte of a file, and reverse the filename.
using System;
using System.IO;
namespace NotFile
{
class Program
{
static void Main(string[] args)
{
foreach (string path in args)
if (File.Exists(path))
{
FileInfo fi = new FileInfo(path);
using (FileStream fsIn = new FileStream(path, FileMode.Open))
using (FileStream fsOut = new FileStream(Path.Combine(fi.DirectoryName, ReverseString(fi.Name)), FileMode.Create))
{
fsIn.Position = 0;
int i = 0;
while ((i = fsIn.ReadByte()) != -1)
fsOut.WriteByte((byte)(~(byte)i));
}
}
}
static string ReverseString(string s)
{
string o = "";
for (int i = 0; i < s.Length; i++)
o = s[i] + o;
return o;
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment