How about asking for free space and then checking? For UNC, DriveInfo cannot be used, so GetDiskFreeSpaceEx API is used.
[DllImport("kernel32.dll", SetLastError = true, CharSet = CharSet.Unicode)]
[return: MarshalAs(UnmanagedType.Bool)]
private static extern bool GetDiskFreeSpaceEx(string lpDirectoryName,
out ulong lpFreeBytesAvailable,
out ulong lpTotalNumberOfBytes,
out ulong lpTotalNumberOfFreeBytes);
private static bool IsDiskFull(string fileName) {
string rootPath = Path.GetPathRoot(fileName);
if (rootPath[rootPath.Length - 1] != Path.DirectorySeparatorChar) {
rootPath += Path.DirectorySeparatorChar;
}
bool result = GetDiskFreeSpaceEx(rootPath,
out var freeBytesAvailable,
out var _,
out var _);
if (!result) {
throw new Win32Exception();
}
return freeBytesAvailable == 0;
}
if (!IsDiskFull(firstFile) && !File.Exists(firstFile)) {
File.Copy(secondFile, firstFile);
}