Can anyone see what is wrong with this code? I dont seem to understand the errors that are:
Error 1 An object reference is required for the non-static field, method, or property 'PenDriveBackup.Program.iDrive'
'Error 2 An object reference is required for the non-static field, method, or property 'PenDriveBackup.Program.GetDriveList()'
Error 3 'PenDriveBackup.Program.GetDriveList()': not all code paths return a value.
The code is:
Code:
using System;
using System.IO;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace PenDriveBackup
{
class Program
{
public string[] iDrive;
public static void Main(string[] args)
{
iDrive = GetDriveList();
//System.Threading.Thread.Sleep(5000);
}
public string GetDriveList()
{
DriveInfo[] aDrives = DriveInfo.GetDrives();
foreach (DriveInfo d in aDrives)
{
if (d.DriveType == DriveType.Removable)
{
//dType = Convert.ToString(d.Name);
return Convert.ToString(d.Name);
}
}
}
}
}

