Example #1
0
        public FolderInfo GetFolderInfo(string path)
        {
            if (!Directory.Exists(path))
            {
                return(null);
            }

            Int64 dirSize = -1;

            try
            {
                Scripting.FileSystemObject fso    = new Scripting.FileSystemObject();
                Scripting.Folder           folder = fso.GetFolder(path);
                dirSize = (Int64)folder.Size;
            }
            catch (Exception ex)
            {
                Log(path + " : " + ex.Message);
            }

            DirectoryInfo dir = new DirectoryInfo(path);

            return(new FolderInfo
            {
                Name = dir.Name,
                FullPath = path,
                Size = dirSize
            });
        }
Example #2
0
        public static long DirSizeScriptingRuntime(DirectoryInfo dir)
        {
            Scripting.FileSystemObject fso    = new Scripting.FileSystemObject();
            Scripting.Folder           folder = fso.GetFolder(dir.FullName);
            long dirSize = (long)folder.Size;

            return(dirSize);
        }
Example #3
0
        public static string GetFolderSize(string folderPath)
        {
            Scripting.FileSystemObject fso    = new Scripting.FileSystemObject();
            Scripting.Folder           folder = fso.GetFolder(folderPath);
            dynamic dirSize       = folder.Size;
            long    dirSizeInt    = Convert.ToInt64(dirSize);
            string  dirSizeString = BytesToString(dirSizeInt);

            return(dirSizeString);
        }
        private string getSerialNumber()
        {
            string functionReturnValue = null;

            Scripting.FileSystemObject fso       = new Scripting.FileSystemObject();
            Scripting.Folder           fsoFolder = default(Scripting.Folder);
            Scripting.Drive            fsoDrive  = default(Scripting.Drive);
            functionReturnValue = "";
            if (fso.FolderExists(modRecordSet.serverPath))
            {
                fsoFolder           = fso.GetFolder(modRecordSet.serverPath);
                functionReturnValue = Convert.ToString(fsoFolder.Drive.SerialNumber);
            }
            return(functionReturnValue);
        }
Example #5
0
        private string getSerialNumber()
        {
            string functionReturnValue = null;

            Scripting.FileSystemObject FSO       = new Scripting.FileSystemObject();
            Scripting.Folder           fsoFolder = default(Scripting.Folder);
            functionReturnValue = "";
            Label4.Text         = modRecordSet.serverPath;
            if (FSO.FolderExists(modRecordSet.serverPath))
            {
                fsoFolder           = FSO.GetFolder(modRecordSet.serverPath);
                functionReturnValue = Convert.ToString(fsoFolder.Drive.SerialNumber);
                Label3.Text         = Convert.ToString(fsoFolder.Drive.SerialNumber);
            }
            return(functionReturnValue);
        }
        private Dictionary <string, long> GetSizesOfItems(IEnumerable <string> filesToMove)
        {
            var sizes = new Dictionary <string, long>(filesToMove.Count());

            foreach (var path in filesToMove)
            {
                if (File.Exists(path))
                {
                    sizes.Add(path, new FileInfo(path).Length);
                }
                else if (Directory.Exists(path))
                {
                    Scripting.FileSystemObject fso    = new Scripting.FileSystemObject();
                    Scripting.Folder           folder = fso.GetFolder(path);
                    sizes.Add(path, (long)folder.Size);
                }
            }
            return(sizes);
        }