在我们实际工作中,有时需要在工作开始之前检查磁盘的可用空间,比如渲染。
当然,我们可以人工很容易查看电脑中各个磁盘的空间使用情况,但是,如果是Maxscript插件完成的工作,那么如何才能实现其工作之前对磁盘空间进行一个核查呢?下面给出一些参考方法,具体还要在实际工作中变通使用。
直接上脚本:
(
drives = (dotnetclass "System.IO.DriveInfo").GetDrives()
for d in drives do
(
format "Name: %
" d.Name
if d.IsReady then
(
format " Available free space: % bytes
" d.AvailableFreeSpace
format " Total available space: % bytes
" d.TotalFreeSpace
format " Total size of drive: % bytes
" d.TotalSize
)
else
(
format " The device is not ready.
"
)
)
)
运行结果:
Name: C:\
Available free space: 60491542528L bytes
Total available space: 60491542528L bytes
Total size of drive: 214749409280L bytes
Name: D:\
Available free space: 159292284928L bytes
Total available space: 159292284928L bytes
Total size of drive: 187598630912L bytes
Name: E:\
Available free space: 43058839552L bytes
Total available space: 43058839552L bytes
Total size of drive: 107373129728L bytes
OK
上面看起来有点复杂,来个简单的:
getDriveSpace "c:"
运行结果:
#(60485013504L, 214749409280L, 60485013504L)