Created
January 26, 2011 18:49
-
-
Save OrigamiTech/797195 to your computer and use it in GitHub Desktop.
Not every byte of a file, and reverse the filename.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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