Click here to Skip to main content
15,890,579 members
Home / Discussions / C#
   

C#

 
AnswerRe: Selecting parts of an uint so always the same size? Pin
Lutosław11-Aug-11 23:40
Lutosław11-Aug-11 23:40 
GeneralRe: Selecting parts of an uint so always the same size? Pin
stephen.darling12-Aug-11 0:21
stephen.darling12-Aug-11 0:21 
GeneralRe: Selecting parts of an uint so always the same size? Pin
jschell12-Aug-11 8:44
jschell12-Aug-11 8:44 
GeneralRe: Selecting parts of an uint so always the same size? Pin
stephen.darling12-Aug-11 9:04
stephen.darling12-Aug-11 9:04 
QuestionOnClosing event doesn't work Pin
MAW3011-Aug-11 11:28
MAW3011-Aug-11 11:28 
AnswerRe: OnClosing event doesn't work Pin
Alan N11-Aug-11 12:50
Alan N11-Aug-11 12:50 
Questionhot to transfer from FTP to local directory on my computer in C# Pin
Gali197811-Aug-11 10:45
Gali197811-Aug-11 10:45 
QuestionUploading File from Client to Server Pin
akosidandan11-Aug-11 9:11
akosidandan11-Aug-11 9:11 
Hello Experts,

I would like ask how I will alow my client(the one browsing the internet) to upload the file into my web server. I set up my web application using the abyss web server so that I can host the website to my local machine, and for the FTP I use filezilla.

Below here is my code but it's only working in my local machine.

using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.IO;
using System.Net;
using System.Web.UI.WebControls;


namespace ftpPractice
{
    public partial class _Default : System.Web.UI.Page
    {
       
        protected void Page_Load(object sender, EventArgs e)
        {

        }

        public void uploadFileUsingFTP(String CompleteFTPPath, String CompleteLocalPat)
        {
            try
            {
                //Create a FTP Request Object and Specfiy a Complete Path
                FtpWebRequest reqObj = WebRequest.Create(CompleteFTPPath) as FtpWebRequest;

                //Call A FileUpload Method of FTP Request Object 
                reqObj.Method = WebRequestMethods.Ftp.UploadFile;

                //If you want to access Resourse Protected You need to give User Name  and PWD
                reqObj.Credentials = new NetworkCredential("Akosidan", "newbie");

                //File Stream obj read the file from local drive
                FileStream streamObj = File.OpenRead(CompleteLocalPat);

                //Store File in Buffer
                byte[] buffer = new byte[streamObj.Length];

                // Read File from Buffer
                streamObj.Read(buffer, 0, buffer.Length);

                //Close FileStream Object Set its Value to nothing
                streamObj.Close();
                streamObj = null;

                //Upload File to ftp://localHost/ set its object to nothing
                reqObj.GetRequestStream().Write(buffer, 0, buffer.Length);
                reqObj = null;

                lblMessage.Text= "File Uploaded Successfully :)";
            }
            catch (Exception error)
            {
                Response.Write(error.ToString());
            }
            
            //fs.Close();
            //Stream ftpstream = ftp.GetRequestStream();
            //ftpstream.Write(buffer, 0, buffer.Length);
            //ftpstream.Close(); 

           
        }

        protected void cmdUpload_Click(object sender, EventArgs e)
        {
            uploadFileUsingFTP("ftp://localhost/recieveSample.txt", "C:\\someUsers\\someFolder\\Desktop\\sample.txt");
            
            
          
        }

        
    }
}


Comments,suggestion or recommendation is so much appreciated.
AkosiDAN <- newbie

AnswerRe: Uploading File from Client to Server Pin
Not Active11-Aug-11 9:40
mentorNot Active11-Aug-11 9:40 
GeneralRe: Uploading File from Client to Server Pin
akosidandan11-Aug-11 16:19
akosidandan11-Aug-11 16:19 
Generalauthenticate in activeMQ using Spring.Nmstemplate in .net Pin
alfhv11-Aug-11 5:34
alfhv11-Aug-11 5:34 
QuestionUSB current value with C# Pin
yury dorofeev11-Aug-11 5:23
yury dorofeev11-Aug-11 5:23 
QuestionC# OOP: sub-property? Pin
Goalie3511-Aug-11 5:12
Goalie3511-Aug-11 5:12 
GeneralRe: C# OOP: sub-property? PinPopular
David198711-Aug-11 5:16
David198711-Aug-11 5:16 
GeneralRe: C# OOP: sub-property? Pin
Pete O'Hanlon11-Aug-11 9:27
mvePete O'Hanlon11-Aug-11 9:27 
GeneralRe: C# OOP: sub-property? Pin
David198711-Aug-11 21:09
David198711-Aug-11 21:09 
GeneralRe: C# OOP: sub-property? Pin
Shameel11-Aug-11 22:26
professionalShameel11-Aug-11 22:26 
AnswerRe: C# OOP: sub-property? PinPopular
Pete O'Hanlon11-Aug-11 5:23
mvePete O'Hanlon11-Aug-11 5:23 
AnswerRe: C# OOP: sub-property? Pin
PIEBALDconsult15-Aug-11 3:05
mvePIEBALDconsult15-Aug-11 3:05 
QuestionOpen web page from C# WinForms Pin
dipuks11-Aug-11 4:09
dipuks11-Aug-11 4:09 
AnswerRe: Open web page from C# WinForms Pin
Eddy Vluggen11-Aug-11 6:18
professionalEddy Vluggen11-Aug-11 6:18 
QuestionIssues in using Observable&lt;T&gt; to fire Property notification events (WinForms) [modified] Pin
BillWoodruff11-Aug-11 3:45
professionalBillWoodruff11-Aug-11 3:45 
AnswerRe: Issues in using Observable<T> to fire Property notification events (WinForms) Pin
BobJanova11-Aug-11 22:27
BobJanova11-Aug-11 22:27 
GeneralRe: Issues in using Observable&lt;T&gt; to fire Property notification events (WinForms) Pin
BillWoodruff11-Aug-11 23:23
professionalBillWoodruff11-Aug-11 23:23 
GeneralRe: Issues in using Observable<T> to fire Property notification events (WinForms) Pin
BobJanova11-Aug-11 23:57
BobJanova11-Aug-11 23:57 

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.