Мне нужно добавить новую информацию о ресурсе ниже кода C#!
Когда я пытаюсь скомпилировать код, я получаю: «ФАЙЛ НЕ НАЙДЕННЫЙ ИСКЛЮЧИТЕЛЬНЫЙ УДАЛ».Как рассчитывать под расширениями? используя C#
Как я могу изменить программу? - В чем причина этого исключения?
Мой файл Xml:
<?xml version="1.0" encoding="utf-8"?>
<Assets>
<Asset>
<assetId></assetId>
<assetName></assetName>
<modelNo></modelNo>
<price></price>
<quantity></quantity>
</Asset>
Мой C# код:
static List<Asset> Assets = new List<Asset>();
public static void AddSingleAsset() {
Asset newAsset = new Asset();
newAsset.assetId = Assets.Count + 1;
Console.WriteLine("Asset ID : {0}", newAsset.assetId);
Console.WriteLine("Enter the asset name");
newAsset.assetName = Console.ReadLine();
Console.WriteLine("Model number :");
newAsset.modelNo = Console.ReadLine();
Console.WriteLine("Price :");
newAsset.price = double.Parse(Console.ReadLine());
Console.WriteLine("Quantity :");
newAsset.quantity = int.Parse(Console.ReadLine());
Assets.Add(newAsset);
string path = "Assets.xml";
XDocument doc = XDocument.Load(path);
doc.Elements("Assets").First().Add(new XElement("Asset", new XAttribute("assetId", newAsset.assetId),
new XElement("assetName", newAsset.assetName),
new XElement("modelNo", newAsset.modelNo),
new XElement("price", newAsset.price),
new XElement("quantity", newAsset.quantity)
));
doc.Save(path);
}
«В чем причина этого исключения?» Я думаю, это ясно. 'FILE NOT FOUND' –