Bluezap's Profile User Rating: -----

Reputation: 5 Worker
Group:
Active Members
Active Posts:
333 (0.31 per day)
Joined:
19-January 12
Profile Views:
3,229
Last Active:
User is online A minute ago
Currently:
Viewing Board Index

Previous Fields

Country:
Who Cares
OS Preference:
Windows
Favorite Browser:
Chrome
Favorite Processor:
Intel
Favorite Gaming Platform:
PC
Your Car:
Volkswagen
Dream Kudos:
0
Icon   Bluezap has not set their status

Posts I've Made

  1. In Topic: Writing to a text file and uploading it to a server directory

    Posted 26 Dec 2014

    I know, wrote it again and fixed everything you mentioned.Thanks !
  2. In Topic: Writing to a text file and uploading it to a server directory

    Posted 25 Dec 2014

    Here's my solution, just took a few minutes to figure out how everything worked -

    public bool ftpTransfer(string fileName)
            {
                try
                {
                    string ftpAddress = "";
                    string username = "";
                    string password = "";
    
                    using (StreamWriter writer = new StreamWriter(fileName))
                       
                    {
    
                        WebRequest request = WebRequest.Create("ftp://" + ftpAddress + "/" + "update" + "/" + fileName);
                        request.Method = WebRequestMethods.Ftp.UploadFile;
                        request.Credentials = new NetworkCredential(username, password);
                        Stream reqStream = request.GetRequestStream();
                        System.IO.StreamWriter SW = new System.IO.StreamWriter(reqStream);
                          SW.WriteLine("YAYYY!");
                       SW.Close();
    
                    }
                    return true;
                }
                catch (Exception ex)
                {
                    Console.WriteLine(ex.ToString());
                    return false;
                }
            }
    
    

    Feel free to correct me if anyone finds an issue with this approach
  3. In Topic: Writing to a text file and uploading it to a server directory

    Posted 25 Dec 2014

    View PostSkydiver, on 25 December 2014 - 08:48 AM, said:

    You obviously just took the traditional way and did not take time to understand how or why it works. Unlike human traditions which may have no real logic behind them, code inherently does have logic in it. Notice that it reads all the data from the file, and then transmits it by writing into the request stream. So if you want to bypass having to use a local file, you could just write directly into the stream.


    Wow, that's deep o.O I admit I was a bit a lazy. Ill figure this out thanks :)
  4. In Topic: Writing to a text file and uploading it to a server directory

    Posted 25 Dec 2014

    EDIT :-

    This is what I have tried, what am I doing wrong here?
    public bool ftpTransfer(string fileName)
            {
                try
                {
                    string ftpAddress = "test.com";
                    string username = "tes";
                    string password = "test";
    
                    using (StreamWriter writer = new StreamWriter(fileName))
                    {
                        writer.Write("test");
                        WebRequest request = WebRequest.Create("ftp://" + ftpAddress + "/" + "update" + "/" + fileName);
                        request.Method = WebRequestMethods.Ftp.UploadFile;
                        request.Credentials = new NetworkCredential(username, password);
                        Stream reqStream = request.GetRequestStream();
                        reqStream.Close();
                    }
                    return true;
                }
                catch (Exception ex)
                {
                    Console.WriteLine(ex.ToString());
                    return false;
                }
            }
    
    
  5. In Topic: Using if statement and loops

    Posted 1 Dec 2014

    View Postandrewsw, on 01 December 2014 - 11:48 AM, said:

                     Console.WriteLine("This is your answer - " + d);
                     Console.WriteLine("_________________________________");
    

    You repeat these lines a number of times. You could just have them once, after the if-block.

    Wow didn't even see that. Noob mistake lol :\

My Information

Member Title:
D.I.C Regular
Age:
19 years old
Birthday:
June 22, 1995
Gender:
Programming Languages:
VB.NET
C languages

Contact Information

E-mail:
Private

Friends

Comments

Bluezap has no profile comments yet. Why not say hello?