What is the best way in .Net to make sure a path as capacity to store a file. I need to makes sure I have room for the file before I download is becasue the source will not allow the file to be downloaded a second time. I have looked at System.IO.DriveInfo but this does not work for UNC paths.
Share
Here’s a short function taken from this page that shows how you can get the free space of any drive (local or network/UNC) using WMI.
If you wnat a Win32 API solution, you can use the
GetDiskFreeSpaceExfunction, as suggested by this MSDN help page. It too seems to support both local and network drive names.If you’re having trouble converting that to C#, let me know.
I would have to recommend the WMI solution here, it being fully managed (aside from fewer lines), but either should do the trick.