0

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-

private static int localPort = 6000 ;
	private static UdpClient receivingUdpClient = new UdpClient(localPort);
	private static IPEndPoint RemoteIpEndPoint = null ;
	private static FileStream fs;
	private static byte[] receiveBytes = new byte[0]; 
		
		
	public static void ReceiveFile()

	{
			try
			{
				
	// Receive file
	receiveBytes = receivingUdpClient.Receive(ref RemoteIpEndPoint);	i++;
	fs = new FileStream(@"E:\recd files\temp"+i+"."+"txt", FileMode.Create,
	FileAccess.ReadWrite, FileShare.ReadWrite);
	fs.Write(receiveBytes, 0, receiveBytes.Length);
	Process.Start(fs.Name);
			}
			catch (Exception e)
			{
				//Console.WriteLine(e.ToString ());
			}
			finally
			{
				fs.Close();
			}
		}
        
protected override void OnStart(string[] args)
{
			
     ReceiveFile();
				
}

any help would be highly appreciated

2
Contributors
2
Replies
3
Views
9 Years
Discussion Span
Last Post by ujwaliyer
0

>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...

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.