From 5e2ea1ae8a96d20c6f2dd03905c9533f6fd43f46 Mon Sep 17 00:00:00 2001 From: "Joel W. Reed" Date: Wed, 28 Mar 2007 20:00:38 -0400 Subject: [PATCH] remove.sample --- sample.cs | 127 -------------------------------------------------------------- 1 file changed, 127 deletions(-) delete mode 100644 sample.cs diff --git a/sample.cs b/sample.cs deleted file mode 100644 index 38621fd..0000000 --- a/sample.cs +++ /dev/null @@ -1,127 +0,0 @@ -using System; -using System.Globalization; -using System.IO; -using System.Net; -using Microsoft.TeamFoundation; -using Microsoft.TeamFoundation.Client; -using Microsoft.TeamFoundation.VersionControl.Client; -using Microsoft.TeamFoundation.VersionControl.Common; - -namespace DirSize -{ - class Program - { - static void Main(string[] args) - { - // Check and get the arguments. - String path; - RecursionType recursion; - VersionControlServer sourceControl; - GetPathAndRecursion(args, out path, out recursion, out sourceControl); - - Item[] items = null; - try - { - // Get the latest version of the information for the items. - Console.WriteLine("path is {0}", path); - ItemSet itemSet = sourceControl.GetItems(path, recursion); - items = itemSet.Items; - } - catch (TeamFoundationServerException e) - { - // We couldn't contact the server, the item wasn't found, - // or there was some other problem reported by the server, - // so we stop here. - Console.Error.WriteLine("Exception: {0}", e.Message); - Environment.Exit(1); - } - - if (items.Length == 0) - { - Console.WriteLine("There are no items for " + path); - } - else - { - Array.Sort(items, Item.Comparer); - - long totalBytes = 0; - int numFiles = 0, numFolders = 0; - String format = "{0,-25} {1,-8} {2, 8} {3}"; - foreach (Item item in items) - { - if (item.ItemType == ItemType.File) - { - // In addition to the information printed, the Item object has - // the changeset version and MD5 hash of the file content as - // properties on item. - numFiles++; - totalBytes += item.ContentLength; - Console.WriteLine(format, - item.CheckinDate.ToLocalTime().ToString("G"), - String.Empty, - item.ContentLength, - item.ServerItem); - } - else - { - numFolders++; - Console.WriteLine(format, - item.CheckinDate.ToLocalTime().ToString("G"), - "", - String.Empty, - item.ServerItem); - } - } - - Console.WriteLine(); - Console.WriteLine("{0} files, {1} folders, {2} bytes", - numFiles, numFolders, totalBytes); - } - } - - private static void GetPathAndRecursion(String[] args, - out String path, out RecursionType recursion, - out VersionControlServer sourceControl) - { - if (args.Length < 3) - { - Console.WriteLine("Usage: dirsize "); - Environment.Exit(1); - } - - // Figure out the server based on either the argument or the - // current directory. - WorkspaceInfo wsInfo = null; - path = Environment.CurrentDirectory; - - if (wsInfo == null) - { - wsInfo = Workstation.Current.GetLocalWorkspaceInfo(Environment.CurrentDirectory); - } - - // Stop if we couldn't figure out the server. - if (wsInfo == null) - { - Console.Error.WriteLine("Unable to determine the server."); - Environment.Exit(1); - } - - Console.WriteLine("Server: {0}", wsInfo.ServerUri.AbsoluteUri); - - TeamFoundationServer tfs = new TeamFoundationServer(wsInfo.ServerUri.AbsoluteUri, - new NetworkCredential(args[1], args[2], args[0])); - - sourceControl = (VersionControlServer)tfs.GetService(typeof(VersionControlServer)); - - // Pick up the recursion, if supplied. By default, - // we want item and its immediate children, if it is a folder. - // If the item is a file, then only the file will be returned. - recursion = RecursionType.OneLevel; - if (args.Length == 1 && args[0] == "/r" || - args.Length == 2 && args[1] == "/r") - { - recursion = RecursionType.Full; - } - } - } -} -- 2.11.4.GIT