I know that, AvailableFreeSpace is possible to use for local drives such as "C:/", "D:/" etc. It also works on network drives.
But now my question is:
Is it possible to view the AvailableFreeSpace of a "Folder" on another IP? I connect to the local drives with this code:
System.IO.DriveInfo _DriveInfo = new DriveInfo(SaveLocation);
When "SaveLocation" is a local drive like "C:\Temp\Folder", than it works fine.
But when there is an IP inside "SaveLocation" it doesn't work. SaveLocation looks like this in that case: "192.168.200.10\c\Data"
This doesn't work and that is the reason for my question. The Exceptionmessage is: {"Object must be a root directory (\"C:\\") or a drive letter (\"C\")."}
I hope you can help me.
As seen in Get available disk free space for a given path on Windows :
Use the winapi function
GetDiskFreeSpaceExto determine free space on a UNC (network) path. For example, create a new VS Project called FreeSpace and paste this as Program.cs:As you can see, this is the exact same code as in the Question linked above, just factored into a class plus the correct
usingdirectives to compile without error. All credits go to https://stackoverflow.com/users/995926/rekireWMI doesn't seem to handle free space on network shares. But for local disks, Windows Management Interface is the way to go: https://msdn.microsoft.com/en-us/library/aa394592(v=vs.85).aspx