digitalmars.D.learn - Disk space used and free size of a Network share folder in Windows
- Vino (7/7) Feb 14 2018 Hi All,
- rikki cattermole (3/12) Feb 14 2018 See:
- psychoticRabbit (26/28) Feb 14 2018 any idea on how I'd convert this C# code to D?
- rikki cattermole (3/41) Feb 14 2018 import core.sys.windows.winbase : GetDiskFreeSpaceEx;
- Vino (22/35) Feb 14 2018 Hi Rikki,
- FreeSlave (3/26) Feb 14 2018 Don't call external processes when you can call a function.
- psychoticRabbit (2/5) Feb 14 2018 writeln(result.output[38..$]);
- Johan Engelen (6/10) Feb 15 2018 See:
- Vino (7/18) Feb 16 2018 Hi All,
Hi All, Request your help on how to get the disk space used and free size of a Network share folder in Windows, tried with getSize but it return 0; eg: Share Name :\\server1\dir1$ From, Vino.B
Feb 14 2018
On 14/02/2018 12:22 PM, Vino wrote:Hi All, Request your help on how to get the disk space used and free size of a Network share folder in Windows, tried with getSize but it return 0; eg: Share Name :\\server1\dir1$ From, Vino.BSee: https://msdn.microsoft.com/en-us/library/windows/desktop/aa364935(v=vs.85).aspx
Feb 14 2018
On Wednesday, 14 February 2018 at 12:29:13 UTC, rikki cattermole wrote:See: https://msdn.microsoft.com/en-us/library/windows/desktop/aa364935(v=vs.85).aspx============================== public class Program { [DllImport("kernel32.dll")] [return:MarshalAs(UnmanagedType.Bool)] static extern bool GetDiskFreeSpaceEx(string lpDirectoryName, out ulong lpFreeBytesAvailable, out ulong lpTotalNumberOfBytes, out ulong lpTotalNumberOfFreeBytes); static void Main() { string dir = "C:\\"; ulong lpFreeBytesAvailable; ulong lpTotalNumberOfBytes; ulong lpTotalNumberOfFreeBytes; GetDiskFreeSpaceEx(dir, out lpFreeBytesAvailable, out lpTotalNumberOfBytes, out lpTotalNumberOfFreeBytes); Console.WriteLine(lpFreeBytesAvailable"); Console.WriteLine(lpTotalNumberOfBytes"); Console.WriteLine(lpFreeBytesAvailable"); } } =================================
Feb 14 2018
On 14/02/2018 1:52 PM, psychoticRabbit wrote:On Wednesday, 14 February 2018 at 12:29:13 UTC, rikki cattermole wrote:import core.sys.windows.winbase : GetDiskFreeSpaceEx; Use wstring's and .ptr them and everything should work.See: https://msdn.microsoft.com/en-us/library/windows/desktop/aa 64935(v=vs.85).aspx============================== public class Program { [DllImport("kernel32.dll")] [return:MarshalAs(UnmanagedType.Bool)] static extern bool GetDiskFreeSpaceEx(string lpDirectoryName, out ulong lpFreeBytesAvailable, out ulong lpTotalNumberOfBytes, out ulong lpTotalNumberOfFreeBytes); static void Main() { string dir = "C:\\"; ulong lpFreeBytesAvailable; ulong lpTotalNumberOfBytes; ulong lpTotalNumberOfFreeBytes; GetDiskFreeSpaceEx(dir, out lpFreeBytesAvailable, out lpTotalNumberOfBytes, out lpTotalNumberOfFreeBytes); Console.WriteLine(lpFreeBytesAvailable"); Console.WriteLine(lpTotalNumberOfBytes"); Console.WriteLine(lpFreeBytesAvailable"); } } =================================
Feb 14 2018
On Wednesday, 14 February 2018 at 12:29:13 UTC, rikki cattermole wrote:On 14/02/2018 12:22 PM, Vino wrote:Hi Rikki, Wouldn't this be easy to use with std.process: execute package and calling wmic.exe, the only problem is i am not sure hot to get the out put without the headings(Caption FreeSpace,Size) any help on same is much appreciated. import std.process: execute; import std.stdio : writeln; void main () { version(Windows) { auto result = execute(["wmic.exe", "logicaldisk", "get", "size,freespace,caption"]); writeln(result.output); } } Output : Caption FreeSpace Size C: 19702837248 180043665408 H: 85580382208 824633720832 From, Vino.BHi All, Request your help on how to get the disk space used and free size of a Network share folder in Windows, tried with getSize but it return 0; eg: Share Name :\\server1\dir1$ From, Vino.BSee: https://msdn.microsoft.com/en-us/library/windows/desktop/aa364935(v=vs.85).aspx
Feb 14 2018
On Wednesday, 14 February 2018 at 15:24:42 UTC, Vino wrote:On Wednesday, 14 February 2018 at 12:29:13 UTC, rikki cattermole wrote:Don't call external processes when you can call a function. Running another process is overhead and not reliable.[...]Hi Rikki, Wouldn't this be easy to use with std.process: execute package and calling wmic.exe, the only problem is i am not sure hot to get the out put without the headings(Caption FreeSpace,Size) any help on same is much appreciated. import std.process: execute; import std.stdio : writeln; void main () { version(Windows) { auto result = execute(["wmic.exe", "logicaldisk", "get", "size,freespace,caption"]); writeln(result.output); } } Output : Caption FreeSpace Size C: 19702837248 180043665408 H: 85580382208 824633720832 From, Vino.B
Feb 14 2018
On Wednesday, 14 February 2018 at 15:24:42 UTC, Vino wrote:...the only problem is i am not sure hot to get the out put without the headings(Caption FreeSpace,Size) any help on same is much appreciated.writeln(result.output[38..$]);
Feb 14 2018
On Wednesday, 14 February 2018 at 12:22:09 UTC, Vino wrote:Hi All, Request your help on how to get the disk space used and free size of a Network share folder in Windows, tried with getSize but it return 0;See: https://github.com/ldc-developers/ldc/blob/f5b05878de6df2ea4a77c37128ad2eae0266b690/driver/cache_pruning.d#L47-L71 and https://issues.dlang.org/show_bug.cgi?id=16487 cheers, Johan
Feb 15 2018
On Thursday, 15 February 2018 at 20:43:32 UTC, Johan Engelen wrote:On Wednesday, 14 February 2018 at 12:22:09 UTC, Vino wrote:Hi All, Thank you very much, was able to successfully use the windows function. From, Vino.BHi All, Request your help on how to get the disk space used and free size of a Network share folder in Windows, tried with getSize but it return 0;See: https://github.com/ldc-developers/ldc/blob/f5b05878de6df2ea4a77c37128ad2eae0266b690/driver/cache_pruning.d#L47-L71 and https://issues.dlang.org/show_bug.cgi?id=16487 cheers, Johan
Feb 16 2018