이 작은 문제가 DriveInfo 클래스에 있습니다. C# - 드라이브가 준비되지 않았습니다. (DriveInfo)
namespace Csp.Test.ConsoleApp
{
public class Program
{
public static void Main()
{
//Create the server object - You will need create a list of the server objects.
Server server = new Server();
//Get all drives information
List<DriveInfo> driveList = DriveInfo.GetDrives().ToList<DriveInfo>();
//Insert information of one server - You will need get information of all servers
server.ServerID = 0; //Here is necessery put PK key. I recommend doing the SQL server will automatically generate the PK.
server.ServerName = string.Concat("Server ", driveList.Count);
//Inserts information in the newServers object
for (int i = 0; i < driveList.Count; i++)
{
ServerDrive serverDrives = new ServerDrive();
//Put here all the information to obeject Server
serverDrives.DriveLabel = driveList[i].Name;
serverDrives.TotalSpace = driveList[i].TotalSize;
serverDrives.DriveLetter = driveList[i].VolumeLabel;
serverDrives.FreeSpace = driveList[i].TotalFreeSpace;
// server.ListServerDrives.Add(serverDrives);
server.ServerDrives.Add(serverDrives);
}
//Add the information to an SQL Database using Linq.
DataClasses1DataContext db = new DataClasses1DataContext(@"sqlserver");
// db.Servers.InsertAllOnSubmit(server);
db.Servers.InsertOnSubmit(server);
db.SubmitChanges();
}
어떤 도움
크게 감사하겠습니다 .. 나는 오류가 "isReady 상태"속성에 고유 한 것을 알고 있지만 난 그냥 그것을 정의하는 방법을 모르겠어요.
당신의 "작은 문제"는 무엇입니까? 코드에서 예상되는 동작이나 실제로 * 수행하는 동작을 설명하지 않았습니다. 또한, 왜 코드가 C# 인 것처럼 보일 때이 태그에 "c"가 표시됩니까? –
제목에 "드라이브가 준비되지 않았습니다"라는 메시지가 표시되면 일반 게시물 상단에 "IsReady"가 강조 표시됩니다 드라이브가 준비되지 않았기 때문에 코드가 실행되지 않습니다 " IsReady "라고 부릅니다. – Ghostyy
@Ghostyy 플로피 및 광학 드라이브와 같은 이동식 미디어가있는 드라이브에서이 문제가 발생할 것으로 생각됩니다. 각 서버에서이 코드를 실행할 계획입니까? – Jodrell