Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7169775
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T15:04:42+00:00 2026-05-28T15:04:42+00:00

Within c#, i can put data to seperate strings. For example the current date

  • 0

Within c#, i can put data to seperate strings.
For example the current date i put to a string called line1 and some info i put to a string called line2.

What i want to do now, is sent these 2 strings to a web adress that handles these lines, and write them into a simple text file. (or can i write to a text file on a website directly from C# ?)

My knowlage of php is very low, but so far i found this code to be working:

<?php 
 $File = "name.txt"; 
 $Handle = fopen($File, 'a');
 $Data = "line1\n"; 
 fwrite($Handle, $Data); 
 $Data = "line2\n"; 
 fwrite($Handle, $Data); 
 print "Data Added"; 
 fclose($Handle); 
 ?>

The C# application is running on a computer, not the website (WPF window).
But now it only has the content of the $Data written to the “name.txt” file.
Does anyone know how i could link the text that is binded to the stings in C3, to the datafields defined in the PHP, so that the text from the strings gets written to the text file on the website? Or would it be possible to write directly to a text file without the php in between ?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-28T15:04:43+00:00Added an answer on May 28, 2026 at 3:04 pm

    So, you have a C# app that you want to use to send 2 bits of data to a PHP based website, and have the website write the data into a file? If that’s what you want, you’ll need to do something like the following…

    On the website, create a receiving PHP file. The bones of it would be something like :

    <?php 
    $File = "name.txt"; 
    $Handle = fopen($File, 'a');
    $line1 = $_GET["line1"] . "\n"; 
    fwrite($Handle, $line1); 
    $line2 = $_GET["line2"]; 
    fwrite($Handle, $line2); 
    print "Data Added"; 
    fclose($Handle); 
    echo "Completed writing data to the file";
    ?>
    

    and to submit that data from the C# app to the website, do something as simple as

    WebClient wc = new WebClient();
    Console.WriteLine(wc.DownloadString("http://example.com/Receiver.php?line1=this is the first line&line2=and this is the second"));
    

    (
    NOTE : No error handling is included in this code, and anyone who knows the URL for the receiver will be able to overwrite your file with whatever they like. Take care when actually implementing this.
    ALSO NOTE : It is years since I did much with PHP, so you will probably need to tweak the code.
    AND ANOTHER THING : the WebClient.DownloadString approach is as basic as it gets. You may want to look at HttpWebRequests if you need more control
    )

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

How can I replace Line Breaks within a string in C#?
How can i get the string within a parenthesis with a custom function? e.x.
How can I concatenate two char columns within a perform screen? example: table sample
I have a doubt in accessing some invalid data. How can the OS cause
Assume that I have some array of data (a vector to be specific). Can
I need to pass my data object within the intent so that called activity
Possible Duplicate: replace in vb.net How to put data containing double-quotes in string variable?
One-to-one relations within nhibernate can be lazyloaded either false or proxy. I was wondering
Is there a pure-Java equivalent to <jsp:forward page=... /> that I can use within
How can I draw a NSString centered within a NSRect ? I've started off

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.