private void GetFilesInFolder(Folder parentFolder, DocumentService docSvc, string filepath, Int32 fileversion, string checkinfile)
 {
     File[] files = docSvc.GetLatestFilesByFolderId(parentFolder.Id, false);
     if (files != null && files.Length > 0)
     {
         foreach (File file in files)
         {
             if (parentFolder.FullName + "/" + file.Name == filepath)
             {
                 for (int vernum = file.VerNum; vernum >= 1; vernum--)
                 {
                     File verFile = docSvc.GetFileByVersion(file.MasterId, vernum);
                     if (vernum == fileversion)
                     {
                         Console.WriteLine(String.Format("{0,12:0,0}", verFile.FileSize) + " " + parentFolder.FullName + "/" + verFile.Name + " (Version " + vernum.ToString() + ")");
                         Console.WriteLine("Writing to " + checkinfile);
                         byte[] bytes;
                         for (int counter = 0; counter < checkinfile.Length; counter++)
                         {
                             if (checkinfile.Substring(counter,1) == "\\")
                             {
                                 try 
                                 {
                                     System.IO.Directory.CreateDirectory(checkinfile.Substring(0,counter));
                                 }
                                 catch (Exception ex)
                                 {
                                     Console.WriteLine(ex.ToString());
                                     Console.WriteLine(checkinfile.Substring(0, counter));
                                 }
                             }
                         }
                         
                         string fileName = docSvc.DownloadFile(verFile.Id, true, out bytes);
                         System.IO.File.WriteAllBytes(checkinfile, bytes);
                     }
                 }
             }
         }
     }
 }