|
Timers are not guaranteed to go off "on time" / interval; only that they won't go off earlier.
"(I) am amazed to see myself here rather than there ... now rather than then".
― Blaise Pascal
|
|
|
|
|
Windows is not a real-time OS. You will get slices that are guaranteed >100ms, but there's never a guarantee that it is executed within a specific time.
You might want to show some code, and explain which timer you are using; there's a few different ones in the framework.
Bastard Programmer from Hell
If you can't read my code, try converting it here[^]
"If you just follow the bacon Eddy, wherever it leads you, then you won't have to think about politics." -- Some Bell.
|
|
|
|
|
Hello,
i am using Visual Studio and C#. I have created a WPF application and i want to read the file.
<window x:class="WpfApplication1.MyDataGrid"
="" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" title="MyDataGrid" height="300" width="300">
{
InitializeComponent();
var xml = XDocument.Load( "c:\\Desktop\\Data.xml" ).Root;
dataGrid1.DataContext = xml;
}
}
}
No error, just empty DataGrid.
I would be thankful for any help.
regards
modified 26-Jan-19 19:47pm.
|
|
|
|
|
Your first item is called "data", the second "data2"; it should also be called "data", otherwise it is not the same "entity" as the row before and will be seen as something completely new.
Also, don't add the unit-names to the data; choose a single unit and make sure that all measurements are converted to it. So one column for volts, and if you encounter a measurement in milliVolts, you convert it to volts first.
Having a unit in there means that each cell is storing two facts instead of one, and that you can't do aritmethic on it using the normal functions. It would be hear-tearing to work with.
Bastard Programmer from Hell
If you can't read my code, try converting it here[^]
"If you just follow the bacon Eddy, wherever it leads you, then you won't have to think about politics." -- Some Bell.
|
|
|
|
|
Thank you for the answer.
modified 26-Jan-19 19:47pm.
|
|
|
|
|
Is not valid XML, so won't work.
XML Validator[^]
Try starting and experimenting with a simpeler example.
Bastard Programmer from Hell
If you can't read my code, try converting it here[^]
"If you just follow the bacon Eddy, wherever it leads you, then you won't have to think about politics." -- Some Bell.
|
|
|
|
|
This xml was created from a programm i am using. There are no empty lines, its all in 1 line, no space. But the rest is really the same.
|
|
|
|
|
Then the program is creating non-valid XML. If you open a tag, you need to close it; the amount of < is larger than the amount of >.
Bastard Programmer from Hell
If you can't read my code, try converting it here[^]
"If you just follow the bacon Eddy, wherever it leads you, then you won't have to think about politics." -- Some Bell.
|
|
|
|
|
The number of opening is sure the same like closing, i have seen i have forgotten one / at the end /Group. but
<systemm> for example appears 1 time there.
|
|
|
|
|
So you changed the XML five minutes ago. It contained an "<blabla <somethingelse=""> ", which isn't allowed. I added the link to the validator so you can validate it yourself. The new example (which I applaud the program for changing so quickly) bis also invalid XML. Spaces aren't allowed in tagnames.
--edit
This was the original example, where the validator pointed out the mismatching opening/closing tags.
<Students Variable="Age"
<Semester>2</Semester>
</Students>
<Students Variable="Age"
<Semester>3</Semester>
</Students>
Bastard Programmer from Hell
If you can't read my code, try converting it here[^]
"If you just follow the bacon Eddy, wherever it leads you, then you won't have to think about politics." -- Some Bell.
|
|
|
|
|
Yes, i didn't make copy and paste i have typed it. I am sorry because of the error, there is really no space in tagname. If its that line, its sure correct, .. now
|
|
|
|
|
1) Unless it's a user control, you almost never use a StackPanel as a "top" content control (of a window); you usually use a Grid; 2 columns in your case. (StackPanels tend to stretch beyond the client area if not "contained").
2) You're confusing the "DataContext" (of a UI Element) with the "ItemSource" of a list-type control.
c# - Show the contents of xml file in wpf window - Stack Overflow
"(I) am amazed to see myself here rather than there ... now rather than then".
― Blaise Pascal
|
|
|
|
|
|
how to work with ms word add in in c# and how to get data from exel(using excel as database)
|
|
|
|
|
|
I'd say... normally... or as usual...
All what you need to do is to create MS Excel application instance, open workbook, provide several operation (for example: copy data between apps), etc. Finally, you need to close a workbook and then close an instance of MS Excell application. Do not forget to clean up by calling below code:
GC.Collect();
GC.WaitForPendingFinalizers();
Marshal.ReleaseComObject(xlSheet);
Marshal.ReleaseComObject(xlBook);<br />
Marshal.ReleaseComObject(xlApp);
Good luck!
|
|
|
|
|
I have the following API Controller with a simple method to accept a file via the IFormfile, which works a treat in Postman. Now I need to call this with a HttpClient call from a console application.
[HttpPost]
public IActionResult PostFile(IFormFile file)
{
Return OK();
}
This is where I am stuck can anyone give me a good couple of examples of creating a PostAsync call so that I can transfer a file to the server?
Thanks
Simon
Every day, thousands of innocent plants are killed by vegetarians.
Help end the violence EAT BACON
|
|
|
|
|
Something like this should work:
public static async Task UploadFile(HttpClient client, string url, string filePath, string contentType, CancellationToken cancellationToken)
{
using (var fileStream = File.OpenRead(filePath))
{
var file = new StreamContent(fileStream);
file.Headers.ContentType = MediaTypeHeaderValue.Parse(mimeType);
file.Headers.ContentLength = fileStream.Length;
var content = new MultipartFormDataContent();
content.Add(file, "file", Path.GetFileName(filePath));
using (var response = await client.PostAsync(url, content, cancellationToken).ConfigureAwait(false))
{
response.EnsureSuccessStatusCode();
}
}
}
"These people looked deep within my soul and assigned me a number based on the order in which I joined."
- Homer
|
|
|
|
|
Richard,
Thanks for this and apologies that I have taken so long to respond, had to tweak your solution slightly to make it work
using (var formData = new MultipartFormDataContent())
{
Task<HttpResponseMessage> responseMessage = null;
using (var stream = File.OpenRead(pdf))
{
HttpContent fileStreamContent = new StreamContent(stream);
fileStreamContent.Headers.ContentDisposition = new System.Net.Http.Headers.ContentDispositionHeaderValue("form-data")
{ Name = "DigitalPCN", FileName = Path.GetFileName(fine.FileName) };
fileStreamContent.Headers.ContentType = new System.Net.Http.Headers.MediaTypeHeaderValue("application/pdf");
formData.Add(fileStreamContent);
responseMessage = base.PostAsync(new Uri(@"https://localhost:44349/api/Controller/Method"), formData, token);
responseMessage.Wait();
}
return responseMessage.Result;
}
Every day, thousands of innocent plants are killed by vegetarians.
Help end the violence EAT BACON
|
|
|
|
|
hello!
i am blind and I am trying to develop a simple SSH client which will help people like me with SSH coomunications.
I am using the Netssh library to achieve this. The following code seems to be faulty, because I get either no error or connection validation.
CODE:
using DavyKager;
using Renci.SshNet;
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
namespace Mao_TTY
{
public partial class DLGConnect : Form
{
public DLGConnect()
{
InitializeComponent();
}
private void DLGConnect_Load(object sender, EventArgs e)
{
Tolk.Load();
}
private void BTNConnect_Click(object sender, EventArgs e)
{
string Address = TXTHost.Text;
string Port = TXTPort.Text;
string UserName = TXTUserName.Text;
string Password = TXTPassword.Text;
int NumPort = Int32.Parse(Port);
SshClient SSHObj = new SshClient(Address, NumPort, UserName, Password);
SSHObj.Connect();
if (!SSHObj.IsConnected)
{
MessageBox.Show("Wystąpił błąd połączenia z serwerem.\nSprawdź czy wszystkie wprowadzone dane są poprawne i spróbuj ponownie", "Błąd");
}
}
}
}
|
|
|
|
|
The SSHObj goes out of scope; the variable is "lost" once the method ends, and is disposed of, connected or not. Try something like below;
SshClient SSHObj = null;
private void BTNConnect_Click(object sender, EventArgs e)
{
string Address = TXTHost.Text;
string Port = TXTPort.Text;
string UserName = TXTUserName.Text;
string Password = TXTPassword.Text;
int NumPort = Int32.Parse(Port);
SSHObj = new SshClient(Address, NumPort, UserName, Password);
SSHObj.Connect();
}
Bastard Programmer from Hell
If you can't read my code, try converting it here[^]
"If you just follow the bacon Eddy, wherever it leads you, then you won't have to think about politics." -- Some Bell.
|
|
|
|
|
Hello,
it still behaves in the same way (when I click connect and values are incorrect, no error in the if statement is raised.)
|
|
|
|
|
What SSH-client are you using? I'd recommend SSH.NET
Also, what are you expecting the thing to do if there is a connection? How about running a command?
Bastard Programmer from Hell
If you can't read my code, try converting it here[^]
"If you just follow the bacon Eddy, wherever it leads you, then you won't have to think about politics." -- Some Bell.
|
|
|
|
|
i am using SSHNet. I want to write a full-fledged client but for now I just would like to test if it works.
|
|
|
|
|
The connect-command will not show a dialog stating that it is connected. If you want to test it, you got to use the connection. There's samples available on the site where you downloaded SSH.NET.
Bastard Programmer from Hell
If you can't read my code, try converting it here[^]
"If you just follow the bacon Eddy, wherever it leads you, then you won't have to think about politics." -- Some Bell.
|
|
|
|