windows service for receiving files thru sockets

Please support our C# advertiser: Intel Parallel Studio Home
Reply

Join Date: Jan 2008
Posts: 14
Reputation: ujwaliyer is an unknown quantity at this point 
Solved Threads: 0
ujwaliyer's Avatar
ujwaliyer ujwaliyer is offline Offline
Newbie Poster

windows service for receiving files thru sockets

 
0
  #1
Jan 16th, 2008
hello everyone,

I have created a console app for receiving files thru sockets.

Now what i need to do is to change it to a windows service so that it will dynamically keep receiving files all the times -- and store them in a separate folder.

The problem is that-

1) am not able to install the service , an exception gets raised. As a result "the windows marks my service for deletion."

here is the code-
  1. private static int localPort = 6000 ;
  2. private static UdpClient receivingUdpClient = new UdpClient(localPort);
  3. private static IPEndPoint RemoteIpEndPoint = null ;
  4. private static FileStream fs;
  5. private static byte[] receiveBytes = new byte[0];
  6.  
  7.  
  8. public static void ReceiveFile()
  9.  
  10. {
  11. try
  12. {
  13.  
  14. // Receive file
  15. receiveBytes = receivingUdpClient.Receive(ref RemoteIpEndPoint); i++;
  16. fs = new FileStream(@"E:\recd files\temp"+i+"."+"txt", FileMode.Create,
  17. FileAccess.ReadWrite, FileShare.ReadWrite);
  18. fs.Write(receiveBytes, 0, receiveBytes.Length);
  19. Process.Start(fs.Name);
  20. }
  21. catch (Exception e)
  22. {
  23. //Console.WriteLine(e.ToString ());
  24. }
  25. finally
  26. {
  27. fs.Close();
  28. }
  29. }
  30.  
  31. protected override void OnStart(string[] args)
  32. {
  33.  
  34. ReceiveFile();
  35.  
  36. }

any help would be highly appreciated
Last edited by ujwaliyer; Jan 16th, 2008 at 2:07 am.
Reply With Quote Quick reply to this message  
Join Date: Sep 2004
Posts: 7,740
Reputation: Narue has a reputation beyond repute Narue has a reputation beyond repute Narue has a reputation beyond repute Narue has a reputation beyond repute Narue has a reputation beyond repute Narue has a reputation beyond repute Narue has a reputation beyond repute Narue has a reputation beyond repute Narue has a reputation beyond repute Narue has a reputation beyond repute Narue has a reputation beyond repute 
Solved Threads: 739
Team Colleague
Narue's Avatar
Narue Narue is offline Offline
Code Goddess

Re: windows service for receiving files thru sockets

 
0
  #2
Jan 16th, 2008
>am not able to install the service , an exception gets raised
What exception?
I'm here to prove you wrong.
Reply With Quote Quick reply to this message  
Join Date: Jan 2008
Posts: 14
Reputation: ujwaliyer is an unknown quantity at this point 
Solved Threads: 0
ujwaliyer's Avatar
ujwaliyer ujwaliyer is offline Offline
Newbie Poster

Re: windows service for receiving files thru sockets

 
0
  #3
Jan 18th, 2008
Originally Posted by Narue View Post
>am not able to install the service , an exception gets raised
What exception?
hi narue,
thanks for taking time for my problem
it says that the operation "did not complete in a timely fashion"

furthurmore- the windows marks my service for "deletion".
so i am not able to use it anymore...
Reply With Quote Quick reply to this message  
Reply

This thread is more than three months old.
Perhaps start a new thread instead?
Message:



Similar Threads
Other Threads in the C# Forum
Thread Tools Search this Thread



About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC