Click here to Skip to main content
15,889,462 members
Home / Discussions / C#
   

C#

 
GeneralRe: How to call a string value from a method within another class? Pin
Karmendra Suthar1-Feb-09 1:00
Karmendra Suthar1-Feb-09 1:00 
AnswerRe: How to call a string value from a method within another class? Pin
Dragonfly_Lee31-Jan-09 20:11
Dragonfly_Lee31-Jan-09 20:11 
QuestionProtect password file Pin
Karmendra Suthar31-Jan-09 19:27
Karmendra Suthar31-Jan-09 19:27 
AnswerRe: Protect password file Pin
Dragonfly_Lee31-Jan-09 20:02
Dragonfly_Lee31-Jan-09 20:02 
GeneralRe: Protect password file Pin
Karmendra Suthar1-Feb-09 0:53
Karmendra Suthar1-Feb-09 0:53 
GeneralRe: Protect password file Pin
Dave Kreskowiak1-Feb-09 1:45
mveDave Kreskowiak1-Feb-09 1:45 
GeneralRe: Protect password file Pin
Dragonfly_Lee1-Feb-09 4:05
Dragonfly_Lee1-Feb-09 4:05 
Questionfile upload error Pin
George_George31-Jan-09 19:22
George_George31-Jan-09 19:22 
Hello everyone,

Here is my code at both client side and server side. My code is simple, just upload a file to an ASP.Net web site.

My client code throws exception when it works on Vista (x64, Enterprise, SP1), but works fine on Windows Server 2003.

Any ideas?

10.10.12.162 is my server address.

Client:

       static void Main(string[] args)
        {
            Console.Write("\nPlease enter the URI to post data to : ");
            String uriString = Console.ReadLine();

            WebClient myWebClient = new WebClient();

            Console.WriteLine("\nPlease enter the fully qualified path of the file to be uploaded to the URI");
            string fileName = Console.ReadLine();
            Console.WriteLine("Uploading {0} to {1} ...", fileName, uriString);

            DateTime begin = DateTime.Now;

            byte[] responseArray = null;
            try
            {
                responseArray = myWebClient.UploadFile(uriString, fileName);
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex.Message);
                Console.WriteLine(ex.ToString());
            }

            DateTime end = DateTime.Now;

            Console.WriteLine("Elapsed time is: {0}", (end - begin).TotalMilliseconds);
        }

Server:

    public partial class FileUploadHandler : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            foreach (string f in Request.Files.AllKeys)
            {
                HttpPostedFile file = Request.Files[f];
                file.SaveAs("D:\\UploadFile\\UploadedFiles\\" + file.FileName);
            }
        }
    }

Exception from client side:

Unable to connect to the remote server
System.Net.WebException: Unable to connect to the remote server ---> System.Net.
Sockets.SocketException: No connection could be made because the target machine
actively refused it 10.10.12.162:1031
   at System.Net.Sockets.Socket.DoConnect(EndPoint endPointSnapshot, SocketAddre
ss socketAddress)
   at System.Net.ServicePoint.ConnectSocketInternal(Boolean connectFailure, Sock
et s4, Socket s6, Socket& socket, IPAddress& address, ConnectSocketState state,
IAsyncResult asyncResult, Int32 timeout, Exception& exception)
   --- End of inner exception stack trace ---
   at System.Net.WebClient.UploadFile(Uri address, String method, String fileNam
e)
   at FileUploadClient.Program.Main(String[] args) in D:\UploadFile\FileUploadClient\Program.cs:line 30


regards,
George
AnswerRe: file upload error Pin
Anthony Mushrow1-Feb-09 2:17
professionalAnthony Mushrow1-Feb-09 2:17 
GeneralRe: file upload error Pin
George_George1-Feb-09 13:59
George_George1-Feb-09 13:59 
Questioncan we add for loop into an arraylist?how? Pin
merryjoy00031-Jan-09 19:19
merryjoy00031-Jan-09 19:19 
AnswerRe: can we add for loop into an arraylist?how? Pin
Dragonfly_Lee31-Jan-09 20:13
Dragonfly_Lee31-Jan-09 20:13 
AnswerRe: can we add for loop into an arraylist?how? Pin
Alan Balkany2-Feb-09 4:00
Alan Balkany2-Feb-09 4:00 
QuestionHow to set JIT type? Pin
Dragonfly_Lee31-Jan-09 19:07
Dragonfly_Lee31-Jan-09 19:07 
AnswerRe: How to set JIT type? Pin
Christian Graus31-Jan-09 22:15
protectorChristian Graus31-Jan-09 22:15 
GeneralRe: How to set JIT type? Pin
Dragonfly_Lee31-Jan-09 22:41
Dragonfly_Lee31-Jan-09 22:41 
AnswerRe: How to set JIT type? Pin
Eddy Vluggen31-Jan-09 23:20
professionalEddy Vluggen31-Jan-09 23:20 
GeneralRe: How to set JIT type? Pin
Dragonfly_Lee1-Feb-09 0:54
Dragonfly_Lee1-Feb-09 0:54 
GeneralRe: How to set JIT type? Pin
Eddy Vluggen1-Feb-09 7:36
professionalEddy Vluggen1-Feb-09 7:36 
GeneralRe: How to set JIT type? Pin
Dragonfly_Lee1-Feb-09 18:19
Dragonfly_Lee1-Feb-09 18:19 
QuestionProblem of Fonts When Export Crystal Report in PDF PinPopular
Wlink31-Jan-09 17:59
Wlink31-Jan-09 17:59 
QuestionPythagorean triplet Pin
Matthew Hazlett31-Jan-09 17:48
Matthew Hazlett31-Jan-09 17:48 
AnswerRe: Pythagorean triplet Pin
Matthew Hazlett31-Jan-09 17:58
Matthew Hazlett31-Jan-09 17:58 
AnswerRe: Pythagorean triplet Pin
Matthew Hazlett31-Jan-09 21:14
Matthew Hazlett31-Jan-09 21:14 
QuestionAutocomplete AJAX Pin
CrimeanTurtle200831-Jan-09 17:05
CrimeanTurtle200831-Jan-09 17:05 

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.