Click here to Skip to main content
15,887,135 members
Home / Discussions / C#
   

C#

 
AnswerRe: Compiler Inside The Program got errors - Gmail Pin
OriginalGriff14-Jul-18 18:43
mveOriginalGriff14-Jul-18 18:43 
AnswerRe: Compiler Inside The Program got errors - Gmail Pin
Eddy Vluggen14-Jul-18 22:51
professionalEddy Vluggen14-Jul-18 22:51 
GeneralRe: Compiler Inside The Program got errors - Gmail Pin
Member 1385811015-Jul-18 1:11
Member 1385811015-Jul-18 1:11 
GeneralRe: Compiler Inside The Program got errors - Gmail Pin
Richard MacCutchan15-Jul-18 2:01
mveRichard MacCutchan15-Jul-18 2:01 
GeneralRe: Compiler Inside The Program got errors - Gmail Pin
Eddy Vluggen15-Jul-18 2:04
professionalEddy Vluggen15-Jul-18 2:04 
GeneralRe: Compiler Inside The Program got errors - Gmail Pin
Member 1385811015-Jul-18 2:58
Member 1385811015-Jul-18 2:58 
AnswerRe: Compiler Inside The Program got errors - Gmail Pin
Dave Kreskowiak16-Jul-18 4:29
mveDave Kreskowiak16-Jul-18 4:29 
QuestionStrings were not posted properly? Pin
codeNewer12-Jul-18 17:24
codeNewer12-Jul-18 17:24 
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
<?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:
C#
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.
AnswerRe: Strings were not posted properly? Pin
Richard Deeming13-Jul-18 1:16
mveRichard Deeming13-Jul-18 1:16 
QuestionHow to select nodes via HtmlAgilityPack? Pin
MohammadRSZ12-Jul-18 12:54
MohammadRSZ12-Jul-18 12:54 
AnswerRe: How to select nodes via HtmlAgilityPack? Pin
Keviniano Gayo13-Jul-18 3:19
Keviniano Gayo13-Jul-18 3:19 
GeneralRe: How to select nodes via HtmlAgilityPack? Pin
MohammadRSZ13-Jul-18 5:07
MohammadRSZ13-Jul-18 5:07 
QuestionHow to uncompress zip file into a folder without external dependencies like Interop.Shell32.dll or 3rd-Party Assemblies? Pin
Kerem Guemruekcue11-Jul-18 18:58
Kerem Guemruekcue11-Jul-18 18:58 
AnswerRe: How to uncompress zip file into a folder without external dependencies like Interop.Shell32.dll or 3rd-Party Assemblies? Pin
Eddy Vluggen12-Jul-18 0:03
professionalEddy Vluggen12-Jul-18 0:03 
GeneralRe: How to uncompress zip file into a folder without external dependencies like Interop.Shell32.dll or 3rd-Party Assemblies? Pin
Kerem Guemruekcue12-Jul-18 0:29
Kerem Guemruekcue12-Jul-18 0:29 
GeneralRe: How to uncompress zip file into a folder without external dependencies like Interop.Shell32.dll or 3rd-Party Assemblies? Pin
Eddy Vluggen12-Jul-18 0:42
professionalEddy Vluggen12-Jul-18 0:42 
GeneralRe: How to uncompress zip file into a folder without external dependencies like Interop.Shell32.dll or 3rd-Party Assemblies? Pin
Kerem Guemruekcue12-Jul-18 1:13
Kerem Guemruekcue12-Jul-18 1:13 
GeneralRe: How to uncompress zip file into a folder without external dependencies like Interop.Shell32.dll or 3rd-Party Assemblies? Pin
Eddy Vluggen12-Jul-18 1:17
professionalEddy Vluggen12-Jul-18 1:17 
GeneralRe: How to uncompress zip file into a folder without external dependencies like Interop.Shell32.dll or 3rd-Party Assemblies? Pin
Kerem Guemruekcue12-Jul-18 1:32
Kerem Guemruekcue12-Jul-18 1:32 
GeneralRe: How to uncompress zip file into a folder without external dependencies like Interop.Shell32.dll or 3rd-Party Assemblies? Pin
Eddy Vluggen12-Jul-18 1:42
professionalEddy Vluggen12-Jul-18 1:42 
GeneralRe: How to uncompress zip file into a folder without external dependencies like Interop.Shell32.dll or 3rd-Party Assemblies? Pin
Kerem Guemruekcue12-Jul-18 1:50
Kerem Guemruekcue12-Jul-18 1:50 
AnswerRe: How to uncompress zip file into a folder without external dependencies like Interop.Shell32.dll or 3rd-Party Assemblies? Pin
Richard Deeming12-Jul-18 2:43
mveRichard Deeming12-Jul-18 2:43 
GeneralRe: How to uncompress zip file into a folder without external dependencies like Interop.Shell32.dll or 3rd-Party Assemblies? Pin
Kerem Guemruekcue12-Jul-18 3:22
Kerem Guemruekcue12-Jul-18 3:22 
QuestionCommunicate With MEF Plugin From Another App Pin
Kevin Marois11-Jul-18 6:29
professionalKevin Marois11-Jul-18 6:29 
AnswerRe: Communicate With MEF Plugin From Another App Pin
Pete O'Hanlon11-Jul-18 7:19
mvePete O'Hanlon11-Jul-18 7:19 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.