RemoteDevice.DriveInfo Problems

Jan 22, 2015 at 10:49 AM
Hi,
I am trying to use RemoteDevice.DriveInfo to get the free space available on my device. I have tried passing the paths in as parameters and hard coding them but I can't get either to work. I always get NULL. Any idea's?
private void bgwGetDeviceFreeSpace_DoWork(object sender, DoWorkEventArgs e)
    {

        RemoteDeviceManager manager = new RemoteDeviceManager();

        device = manager.Devices.FirstConnectedDevice;

        DeviceFreeSpaceObject deviceFreeSpaceObject = e.Argument as DeviceFreeSpaceObject;

        RemoteDevice.DriveInfo hddInfo = new RemoteDevice.DriveInfo();

        RemoteDevice.DriveInfo sdCardInfo = new RemoteDevice.DriveInfo();

        if (deviceFreeSpaceObject.deviceHDDPath != string.Empty)
        {

            //hddInfo = device.GetDriveInfo(deviceFreeSpaceObject.deviceHDDPath); // @"\"
            hddInfo = device.GetDriveInfo(@"\"); 

        }

        if (deviceFreeSpaceObject.deviceSDCardPath != string.Empty)
        {

            //sdCardInfo = device.GetDriveInfo(deviceFreeSpaceObject.deviceSDCardPath); // "\\SD Card"
            sdCardInfo = device.GetDriveInfo(@"\SD Card"); 

        }

        e.Result = deviceFreeSpaceObject;

    }

    //-----------------------------------------------------------------------------------------------

    private void bgwGetDeviceFreeSpace_RunWorkerCompleted(object sender, RunWorkerCompletedEventArgs e)
    {

        if (e.Error != null)
        {

            string methodName = System.Reflection.MethodBase.GetCurrentMethod().Name;

            lbLogging.Items.Add("2085\t" + DateTime.Now.ToString() + "\tException\t\t" + methodName + " - " + "bgwGetDeviceFreeSpace_RunWorkerCompleted");

            SendErrorReportDataToProtex(methodName, "bgwGetDeviceFreeSpace_RunWorkerCompleted", (e.Error as Exception).ToString());

            return;

        }

        DeviceFreeSpaceObject deviceFreeSpaceObject = e.Result as DeviceFreeSpaceObject;

    }

    //-----------------------------------------------------------------------------------------------
Thanks
Paul.
Jan 22, 2015 at 11:24 AM
Got it working, never assigned the information to anything!

private void bgwGetDeviceFreeSpace_DoWork(object sender, DoWorkEventArgs e)
    {

        RemoteDeviceManager manager = new RemoteDeviceManager();

        device = manager.Devices.FirstConnectedDevice;

        DeviceFreeSpaceObject deviceFreeSpaceObject = e.Argument as DeviceFreeSpaceObject;

        RemoteDevice.DriveInfo hddInfo = new RemoteDevice.DriveInfo();

        RemoteDevice.DriveInfo sdCardInfo = new RemoteDevice.DriveInfo();

        if (deviceFreeSpaceObject.deviceHDDPath != string.Empty)
        {

            hddInfo = device.GetDriveInfo(deviceFreeSpaceObject.deviceHDDPath); // @"\"
            deviceFreeSpaceObject.deviceHDDTotalSize = hddInfo.TotalSize;
            deviceFreeSpaceObject.deviceHDDAvailableFreeSpace = hddInfo.AvailableFreeSpace;
            deviceFreeSpaceObject.deviceHDDTotalFreeSpace = hddInfo.TotalFreeSpace;

        }

        if (deviceFreeSpaceObject.deviceSDCardPath != string.Empty)
        {

            sdCardInfo = device.GetDriveInfo(deviceFreeSpaceObject.deviceSDCardPath); // "\\SD Card"
            deviceFreeSpaceObject.SDCardTotalSize = sdCardInfo.TotalSize;
            deviceFreeSpaceObject.SDCardAvailableFreeSpace = sdCardInfo.AvailableFreeSpace;
            deviceFreeSpaceObject.SDCardTotalFreeSpace = sdCardInfo.TotalFreeSpace;

        }

        e.Result = deviceFreeSpaceObject;

    }