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 }); }
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); }
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); }
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); }