我正在尝试从远程计算机查找我的NAS机器上的可用磁盘空间。为此,我的Python脚本使用以下代码:
import ctypes
fbytes = ctypes.c_ulonglong(0)
tbytes = ctypes.c_ulonglong(0)
path = "<My NAS path>"
success = ctypes.windll.kernel32.GetDiskFreeSpaceExW(ctypes.c_wchar_p(path),ctypes.pointer(fbytes),ctypes.pointer(tbytes), None)
free_bytes = fbytes.value
total_bytes = tbytes.value这找不到正确的值。在我的NAS机器上,我有两个分区。作为NAS驱动器共享的分区几乎有380 8GB的可用空间,但另一个分区有8 8GB的可用空间。上面的代码给了我8 8GB的可用空间,而不是380 8GB。
发布于 2015-10-13 17:27:51
结果取决于path变量的值;在我的NAS上,我有12个共享,在3个分区上,指定不同的一个将返回保存它的分区的值;例如:
path = r'\\NAS\photo'
...
print free_bytes # returns 380098863104L
...
...
path = r'\\NAS\docs'
...
print free_bytes # returns 91234780389Lhttps://stackoverflow.com/questions/33094758
复制相似问题