當我執行下面的代碼時,它會導致錯誤,請幫我解決這個問題。錯誤:System.IO.IOException:沒有找到網絡路徑
class MySample
{
public static void Main()
{
string eventLogName = "Security";
string sourceName = "BTHUSB";
string machineName = "v.i.com";
EventLog eventLog;
eventLog = new EventLog();
eventLog.Log = eventLogName;
eventLog.Source = sourceName;
eventLog.MachineName = machineName;
foreach (EventLogEntry log in eventLog.Entries.Cast<EventLogEntry>().Reverse())// Entries.Cast<EventLogEntry>().Reverse
{
Console.WriteLine(") Entry type: {0} , Category: {1}, Data: {2}, ID: {3}, Source: {4} \n", log.EntryType, log.TimeWritten, log.EventID, log.InstanceId, log.Source);
}
}
}
錯誤是,
Unhandled Exception: System.IO.IOException: The network path was not found. at Microsoft.Win32.RegistryKey.Win32ErrorStatic(Int32 errorCode, String str) at Microsoft.Win32.RegistryKey.OpenRemoteBaseKey(RegistryHive hKey, String ma chineName) at System.Diagnostics.EventLog.GetEventLogRegKey(String machine, Boolean writ able) at System.Diagnostics.EventLog.Exists(String logName, String machineName) at System.Diagnostics.EventLog.OpenForRead(String currentMachineName) at System.Diagnostics.EventLog.GetEntryAtNoThrow(Int32 index) at System.Diagnostics.EventLogEntryCollection.EntriesEnumerator.MoveNext() at System.Linq.Enumerable.<CastIterator>d__aa`1.MoveNext() at System.Linq.Buffer`1..ctor(IEnumerable`1 source) at System.Linq.Enumerable.<ReverseIterator>d__99`1.MoveNext() at event.MySample.Main() in E:\.net prep\.net examples\event\event\Program.cs :line 42
請幫我解決這個問題,在一臺機器名稱字段如何輸入遠程計算機,當它有VICOM,但該系統名稱只有v。
你試圖通過類似'\\計算機名\ $ E做\'也是該機器上的文件夾名稱真的'.NET例子\'你可以從你的機器用'\\計算機名\ $到達機驅動器的路徑..? – MethodMan 2013-02-08 12:27:19