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

>am not able to install the service , an exception gets raised
What exception?

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

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.