|
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.
|
|
|
|
|
Ah, I thout that "IsConnected" property will give me the result I want.
|
|
|
|
|
If the "connect" method is blocking, then yes. If connected, then "nothing" would happen, since the "if" doesn't have an "else" part.
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'm putting a quote together to scan some multi-part forms that are Dot Matrix printed and OCR the packing list number off them for later processing. All I need is the one number off it. Once I have the number I can lookup the contents.
The original intention was to write a c# winforms app, have the op drop the packing lists in the Kyocera copier scanner and save the images to a folder on the server. Then run the app and OCR each image and rename them and store them for recall.
I wrote a test program and tried the Microsoft Ocr, the Iron Ocr, dabbled with the Matrox MIL but backed off it because it required way more time to learn. I can get partial numbers but never got a complete number.
I understand that the 9 pin dot matrix is really low resolution and doesn't create perfect type.
Thought about trying to reprogram the printer to produce letter quality dot matrix on just the number, but it's DOS program and I'm not sure if I can change the template without recompiling the program; I don't know how to compile old Foxpro.
Maybe I'll drop the OCR idea and go another direction.
Does anyone have any experience with this? Any Ideas?
If it ain't broke don't fix it
Discover my world at jkirkerx.com
|
|
|
|
|
jkirkerx wrote: 9 pin dot matrix Wow that is so 80s tech. I am not surprised you are having trouble getting OCR to read it. I would suggest going to ink jet/laser but I guess multi part forms are embedded in their procedures.
Can you up the contrast on the printer, or get the printer to add a bar code although that will probably be as difficult to read as well.
Never underestimate the power of human stupidity -
RAH
I'm old. I know stuff - JSOP
|
|
|
|
|
I found the printer code template for that form yesterday and I think I can edit it and go without compiling.
Make that number bold and letter quality LQ.
I'm going to a manufacture Thursday, Viewsonic and I'll take a look at how they do it.
I'm thinking about laser printing the form on colored NCR paper, changing the print process and media.
Yes very 80's. But the accounting program is rock solid however and very lightweight.
If it ain't broke don't fix it
Discover my world at jkirkerx.com
|
|
|
|