|
Tried to use email for both, but still the same error, while when i use Console.WriteLine(email, password); it shows the same as the ones ive written.
|
|
|
|
|
You need to use your debugger to see exactly what value is being used when the program runs.
|
|
|
|
|
Member 13858110 wrote: Tried to use email for both, but still the same error, while when i use Console.WriteLine(email, password); it shows the same as the ones ive written. The FormatException will be thrown when the "to" adress is in the wrong format. It may contain a newline, or something else, but it is not thrown at random. If it contains multiple addresses, separate them with a comma, not a ";".
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.
|
|
|
|
|
fixed it, it was a format changer ive added, but removed it.
|
|
|
|
|
Why on earth are you doing it this way when you could just put the required values in the app.config file and load them from there, skipping the entire process of compiling code?
|
|
|
|
|
Hi everyone, I am a freshman in C# and php. I currently followed this link: ESP8266 Communication With Server and ESP8266[^] and tried to play with ESP8266.
The arduino part worked fine and I could get the message from a file in my website called datastorage.txt, and below is the php file (named as writefile.php) for me to add message into the txt file:
<?php
$val = $_GET["data"];
$fileContent=$val."\n";
$fileStatus=file_put_contents("datastorage.txt",$fileContent,FILE_APPEND);
if($fileStatus != false)
{
echo "SUCCESS. Data written in file.";
}
else
{
echo "FAIL. Could not connect to file.";
}
?>
If I need to add new message, I always need to enter url like: http://abc.com/writefile.php?data=helloworld (the message would be helloworld in this case), which is not convenient at all.
Therefore, I tried to build a winform to contact with the writefile.php as below:
private void SendBtn_Click(object sender, EventArgs e)
{
SendData();
}
private void SendData()
{
string text = TextBox.Text;
string post = "data=" + text;
byte[] data = Encoding.ASCII.GetBytes(post);
HttpWebRequest req = (HttpWebRequest)WebRequest.Create("http://abc.com/writefile.php");
req.Method = "POST";
req.ContentType = "application/x-www-form-urlencoded";
req.ContentLength = data.Length;
Stream stream = req.GetRequestStream();
stream.Write(data, 0, data.Length);
stream.Close();
}
When I typed a message into the textbox and click "send" button, no error appeared. However, I tried to open datastorage.txt inside my website, and the file only added a blank character " " in the new line but not my text message.
Am I using a wrong method / direction to build the winform?? Thanks very much.
|
|
|
|
|
codeNewer wrote: $val = $_GET["data"]; codeNewer wrote: req.Method = "POST";
You need to understand the difference between GET and POST requests:
HTTP Methods GET vs POST[^]
Your PHP code is reading the variable from the querystring. Your C# code is sending the variable in the request body.
You either need to modify your PHP code to check the $_POST as well as the $_GET ; or modify your C# code to make a GET request.
You also need to modify your C# code to actually send the request.
private void SendData()
{
string text = TextBox.Text;
string url = "http://abc.com/writefile.php?data=" + Uri.EscapeDataString(text);
HttpWebRequest req = (HttpWebRequest)WebRequest.Create(url);
req.Method = "GET";
using (var response = req.GetResponse())
{
}
}
"These people looked deep within my soul and assigned me a number based on the order in which I joined."
- Homer
|
|
|
|
|
I have just practise to grab some data from a web page.
Of course, I am new in c#.
I am using regex but it does not word. and return null.
using HtmlAgilityPack;
namespace ConsoleApp1
{
class Program
{
static void Main(string[] args)
{
HtmlWeb web = new HtmlWeb();
HtmlDocument doc = web.Load("https://www.videoblocks.com/video/after-effects-cs5-template-bracket-titles-65zdx8e");
var title = doc.DocumentNode.SelectNodes(xpath: "//ul[@class='stockItemInfo-stockSpec']").FirstOrDefault().InnerText.Split(':').FirstOrDefault();
var secp = doc.DocumentNode.SelectNodes("//ul[@class='stockItemInfo-stockSpec']//li//span").FirstOrDefault().InnerText;
Console.Write(title+":"+secp);
Console.ReadKey();
}
}
}
|
|
|
|
|
You can check the documentation in Html Agility Pack - documentation[HTML Agility Pack]
It is different from regex.
You can hit a breakpoint in "doc" variable and debug, then it will be easier to inspect the elements on how to navigate it.
[Signature space for sale]
|
|
|
|
|
thanks for your reply
Could you tell me how can I add the breakpoint in doc?
|
|
|
|
|
Hi,
i am looking for a way to extract the entire content of a zip file into a folder without using any external dependencies like Interop.Shell32.dll or 3rd-Party Libs like DotNetZip etc. The entire thing should run from within a single assembly. I personally would like to use the Windows build-in ZIP-Shell extension available from windows XP to Win10 by accessing it with preferably late binding via .NET/C#, but i am kinda stuck on how to do it and what the COM-Interfaces/Types for that should look like. Any help would be really higly appreciated.
best
K.
-----------------------
Beste Grüsse / Best regards / Votre bien devoue
Kerem Gümrükcü
-----------------------
"This reply is provided as is, without warranty express or implied."
|
|
|
|
|
Zipping using System.IO.Compression[^]
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.
|
|
|
|
|
Hi Eddy,
thanks for the answer. I forgot one thing to mention here, that the application is using the 2.0 .NET Framework and cant compiled against anything else for compatibility use with other libraries/references included. The System.IO.Compression needs at least 4.5 Framework.
best
K.
-----------------------
Beste Grüsse / Best regards / Votre bien devoue
Kerem Gümrükcü
-----------------------
"This reply is provided as is, without warranty express or implied."
|
|
|
|
|
Kerem Guemruekcue wrote: I forgot one thing to mention here, that the application is using the 2.0 .NET Framework and cant compiled against anything else for compatibility use with other libraries/references included. The System.IO.Compression needs at least 4.5 Framework. It doesn't; it is part of 2.0.
See MSDN[^].
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 is true in terms of availability of the namespace, but the unzipping zip file classes are available starting 4.5 FW. See for yourself: ZipFile Class (System.IO.Compression)[^]
-----------------------
Beste Grüsse / Best regards / Votre bien devoue
Kerem Gümrükcü
-----------------------
"This reply is provided as is, without warranty express or implied."
|
|
|
|
|
Kerem Guemruekcue wrote: This is true in terms of availability of the namespace, but the unzipping zip file classes are available starting 4.5 FW. See for yourself You are referring to a helper-class that simplifies the tasks. The GZipStream is available in 2.0, and you could zip/unzip in 2.0 without using third-party libraries. Example on MSDN[^].
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 not sure how this will help me to unpack a zip file into a folder. The example there only shows how to compress/decompress a single file with GZip compression. I am familiar with that mechanism and it would be overkill to reinvent a library from Deflate/GZip classes in .NET to create a unpacker for folders packet into a zip container file. The example works just fine on a single file, but not on a Zip archive.
-----------------------
Beste Grüsse / Best regards / Votre bien devoue
Kerem Gümrükcü
-----------------------
"This reply is provided as is, without warranty express or implied."
|
|
|
|
|
Kerem Guemruekcue wrote: I am not sure how this will help me to unpack a zip file into a folder. The example there only shows how to compress/decompress a single file with GZip compression. I am familiar with that mechanism and it would be overkill to reinvent a library from Deflate/GZip classes in .NET to create a unpacker for folders packet into a zip container file. Then use one of the existing libraries. Did you not state you did not want a dependency on things like SharpZipLib and DotNetZip?
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.
|
|
|
|
|
Quote: Then use one of the existing libraries. Did you not state you did not want a dependency on things like SharpZipLib and DotNetZip?
Yes, i did and thats why i was prefering the late binding option to the shell zip functionality build into windows. As said, the entire thing should be running from a single exe file with no extra libs attached. the zip com extension is available from XP up to 10. using the GZip/Deflate classes in that namespace supporting .NET 2.0 would require to implement a full unzipper for zip containers in zip format like implemented in the helper classes available starting 4.5 FW. that would be a total overkill.
-----------------------
Beste Grüsse / Best regards / Votre bien devoue
Kerem Gümrükcü
-----------------------
"This reply is provided as is, without warranty express or implied."
|
|
|
|
|
|
Hi Richard,
thanks for the answer. Yes, i have seen that article before, but this uses early binding with a com wrapper. Thats the easy way, but i am looking for late binding at runtime with no additionall assembly file, like this project uses.
best
K.
-----------------------
Beste Grüsse / Best regards / Votre bien devoue
Kerem Gümrükcü
-----------------------
"This reply is provided as is, without warranty express or implied."
|
|
|
|
|
I have a MEF plugin that runs test for a medical instrument. The instrument starts the test service, and that service loads the MEF plugin and calls it's Execute method. This all runs in another thread.
The MEF plugin gets its settings from a Config file. Changes are made to the Config file using an editor designed for it. This editor is a stand alone EXE not connected to the instrument in any way.
The configuration can be set to run the tests for [n] times. This gives techs time to look at the instrument while its running.
1) Instrument starts the test process.
2) Test process loads the MEF plugin.
3) MEF plugin reads config file.
4) Tests inside the plugin execute using settings from config file.
5) At end of test, start next iteration until [n] is reached. Goto step 4.
What I'm wondering is this... Is it possible for an external EXE to somehow get data from the MEF plugin in real time? And, it also could commands be sent into the plugin, such as stop, pause, etc?
Thanks
If it's not broken, fix it until it is.
Everything makes sense in someone's mind.
Ya can't fix stupid.
|
|
|
|
|
You could easily use self-hosted WCF to do this. Set it up to publish messages via named pipes and it'll run no problem.
This space for rent
|
|
|
|
|
Thanks, I'll look into that
If it's not broken, fix it until it is.
Everything makes sense in someone's mind.
Ya can't fix stupid.
|
|
|
|
|
I don't like the bloat of WCF, but you can do secure named pipes pretty trivially without it.
"Never attribute to malice that which can be explained by stupidity."
- Hanlon's Razor
|
|
|
|