Inheritance: System.Web.Services.Protocols.SoapHttpClientProtocol
        private void ProcessFilesInFolder(Folder parentFolder, DocumentService docSvc, string rootfolder, Boolean hidden)
        {
            VaultDump.Document.File[] files = docSvc.GetLatestFilesByFolderId(parentFolder.Id, hidden);
            if (files != null && files.Length > 0)
            {
                foreach (VaultDump.Document.File file in files)
                {
                    for (int vernum = file.VerNum; vernum >= file.VerNum; vernum--)
                    {
                        VaultDump.Document.File verFile = docSvc.GetFileByVersion(file.MasterId, vernum);
                        Console.WriteLine("");
                        Console.WriteLine(" " + parentFolder.FullName + "/" + verFile.Name + " (Version " + vernum.ToString() + ")");
                        Console.WriteLine(" Created By: " + verFile.CreateUserName);
                        //Console.WriteLine(" Comment: " + verFile.Comm);
                        //Console.WriteLine("             Master ID: " + String.Format("{0,6:0,0}", verFile.MasterId) + " ID: " + String.Format("{0,6:0,0}", verFile.Id));
                        //byte[] bytes;
                        string outputfile = rootfolder + parentFolder.FullName.Substring(1) + "/" + verFile.Name;
                        outputfile = outputfile.Replace("/", "\\");
                        for (int counter = 0; counter < outputfile.Length; counter++)
                        {
                            if (outputfile.Substring(counter, 1) == "\\")
                            {
                                try
                                {
                                    System.IO.Directory.CreateDirectory(outputfile.Substring(0, counter));
                                }
                                catch (Exception ex)
                                {
                                    Console.WriteLine(ex.ToString());
                                    Console.WriteLine(outputfile.Substring(0, counter));
                                }
                            }
                        }

                        try
                        {
                            //string fileName = docSvc.DownloadFile(verFile.Id, true, out bytes);
                            //System.IO.File.WriteAllBytes(outputfile, bytes);
                            DownloadFileInParts(verFile, docSvc, outputfile);
                        }
                        catch (Exception ex)
                        {
                            Console.WriteLine("ERROR: Saving " + parentFolder.FullName + "/" + verFile.Name + " (Version " + vernum.ToString() + ")");
                            Console.WriteLine(ex.Message.ToString());
                        }

                        //Console.ReadLine();
                    }
                }
            }

            Folder[] folders = docSvc.GetFoldersByParentId(parentFolder.Id, false);
            if (folders != null && folders.Length > 0)
            {
                foreach (Folder folder in folders)
                {
                    ProcessFilesInFolder(folder, docSvc, rootfolder, hidden);
                }
            }
        }
        public void RunCommand(string server, string vault, string username, string password, string rootfolder, Boolean hidden)
        {
            SecurityService secSrv = new SecurityService();
            secSrv.SecurityHeaderValue = new VaultDump.Security.SecurityHeader();
            secSrv.Url = "http://" + server + "/AutodeskDM/Services/SecurityService.asmx";

            try 
            {
                secSrv.SignIn(username, password, vault);
                DocumentService docSrv = new DocumentService();
                docSrv.SecurityHeaderValue = new VaultDump.Document.SecurityHeader();
                docSrv.SecurityHeaderValue.UserId = secSrv.SecurityHeaderValue.UserId;
                docSrv.SecurityHeaderValue.Ticket = secSrv.SecurityHeaderValue.Ticket;
                docSrv.Url = "http://" + server + "/AutodeskDM/Services/DocumentService.asmx";
                Folder root = docSrv.GetFolderRoot();
                //root = docSrv.GetFolderByPath("$/Designs/Designs/C690 T3");
                //root = docSrv.GetFolderByPath("$/Code Numbers");
                ProcessFilesInFolder(root, docSrv, rootfolder, hidden);
            }
            catch (Exception ex)
            {
                Console.WriteLine("Error: " + ex.ToString());
                return;
            }
        }
        private void DownloadFileInParts(Document.File file, DocumentService docSvc, string outputfile)
        {
            int MAX_BUFFER_SIZE = 1024 * 1024 * 4;    // 49 MB buffer size
            System.IO.FileStream outputStream = null;

            try
            {
                long startByte = 0;
                long endByte;

                // create the output file
                outputStream = System.IO.File.OpenWrite(outputfile);

                // for each loop, the MAX_BUFFER_SIZE number of bytes gets downloaded from the server and written
                // to disk
                while (startByte < file.FileSize)
                {
                    byte[] buffer; 
                    endByte = startByte + MAX_BUFFER_SIZE;
                    if (endByte > file.FileSize)
                        endByte = file.FileSize;

                    // grab the file part from the server
                    buffer = docSvc.DownloadFilePart(file.Id, startByte, endByte, true);

                    // write the data to the file
                    outputStream.Write(buffer, 0, buffer.Length);

                    startByte += buffer.Length;
                }
            }
            finally
            {
                if (outputStream != null)
                    outputStream.Close();
            }
        }