Reputation: 477
I just figuered out how to read my XML in the dataset. Everything worked fine and after I started with encryption and decryption the ReadXML stopped working.
FTP.DownloadFile();
DataSet dataSet = new DataSet();
String encrypted = File.ReadAllText(Path.GetTempPath() + "\\lagerbestand.xml");
//String decrypted = StringCipher.DecryptString(encrypted, "XXXXX");
//MessageBox.Show(decrypted);
dataSet.ReadXml(encrypted);
dataGridView.DataSource = dataSet.Tables[0];
The dataSet.ReadXML(encrypted); gives me an exception.
Illegal letters in the path.
The path is correct, the String encrypted is also filled. The encrypted String looks like the following:
"<NewDataSet>\r\n <Table1>\r\n <Artikelname>1</Artikelname>\r\n <Artikelnummer>2</Artikelnummer>\r\n <Lieferant>3</Lieferant>\r\n <Bestand>4</Bestand>\r\n <Artikelbeschreibung>5</Artikelbeschreibung>\r\n <Min-Lagermenge>6</Min-Lagermenge>\r\n <Einkauf>7</Einkauf>\r\n <Verkauf>8</Verkauf>\r\n </Table1>\r\n</NewDataSet>"
Upvotes: 2
Views: 294
Reputation: 702
ReadXML expects a file path
You should try this way
DataSet dataSet = new DataSet();
String encrypted = File.ReadAllText(Path.GetTempPath() + "\\lagerbestand.xml");
//String decrypted = StringCipher.DecryptString(encrypted, "BeRo-0sT:De0asdnjkinu786*!");
//MessageBox.Show(decrypted);
StringReader sr = new StringReader(encrypted);
dataSet.ReadXml(sr);
Upvotes: 2
Reputation: 51
The method expects a file path not the actual xml.
See: https://learn.microsoft.com/en-us/dotnet/api/system.data.dataset.readxml?view=netframework-4.8
This should work:
dataSet.ReadXML(Path.GetTempPath() + "\\lagerbestand.xml");
Upvotes: 2