473,396 Members | 1,998 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

windows services to move files from one folder to another

windows services to move files from one folder to another folder

hi all,

im working on windows services. c sharp.
all i hav to do is :

i hav 4 controls . 2 datetime controls and 2 textboxes.

2 datetime controls to accept starttime and endtime.
2 textboxes to accept the sourcefilepath and destinationfilepath.

windows service should run all the time. Between the starttime and endtime, files should be copied from the folder in sourcefilepath to the folder in destinationfilepath.

i've use app.config to store and retrieve the starttime, endtime,sourcefilepath and destinationfilepath


Following is my Service OnStart method:

Expand|Select|Wrap|Line Numbers
  1. protected override void OnStart()
  2.         {
  3.             //string from = @"C:\Documents and Settings\Administrator\Desktop\niru\Notepads\From";
  4.             //string to = @"C:\Documents and Settings\Administrator\Desktop\niru\Notepads\To";
  5.  
  6.            string startTime = ConfigurationManager.AppSettings["starttime"];
  7.             string endTime = ConfigurationManager.AppSettings["endtime"];
  8.             string from = ConfigurationManager.AppSettings["from"];
  9.             string to = ConfigurationManager.AppSettings["to"];
  10.  
  11.             DateTime startTimeDt = Convert.ToDateTime(startTime);
  12.             DateTime endTimeDt = Convert.ToDateTime(endTime);
  13.             DateTime currTimeDt = DateTime.Now;
  14.  
  15.             if (currTimeDt >= startTimeDt && currTimeDt <= endTimeDt)
  16.             {
  17.                 File.Move(from, to);
  18.             }
  19.         }
  20.  
Following is my windows form code behind file:
Expand|Select|Wrap|Line Numbers
  1. using System;
  2. using System.Collections.Generic;
  3. using System.ComponentModel;
  4. using System.Data;
  5. using System.Drawing;
  6. using System.Linq;
  7. using System.Text;
  8. using System.Windows.Forms;
  9. using System.Configuration;
  10. using FileTransferServices;
  11.  
  12.  
  13.  
  14. namespace FileTransferWinForm
  15. {
  16.     public partial class FileTranferForm : Form
  17.     {
  18.         //FileTransferServices.FileTransferServices fts = new FileTransferServices.FileTransferServices();
  19.         //FileTransferProperty ftp = new FileTransferProperty();
  20.  
  21.         public FileTranferForm()
  22.         {
  23.             InitializeComponent();
  24.         }
  25.  
  26.         private void FileTranferForm_Load(object sender, EventArgs e)
  27.         {
  28.             //endtime_dtp.Format = DateTimePickerFormat.Time;
  29.             //endtime_dtp.ShowUpDown = true;
  30.  
  31.             string startTime = ConfigurationManager.AppSettings["starttime"];
  32.             string endTime = ConfigurationManager.AppSettings["endtime"];
  33.             string from = ConfigurationManager.AppSettings["from"];
  34.             string to = ConfigurationManager.AppSettings["to"];
  35.  
  36.             //starttime_dtp.Text = startTime;
  37.             //endtime_dtp.Text = endTime;
  38.             //frm_txt.Text = from;
  39.             //to_txt.Text = to;
  40.  
  41.         }
  42.  
  43.         private void frm_txt_TextChanged(object sender, EventArgs e)
  44.         {
  45.             //ftp.From = frm_txt.Text;
  46.         }
  47.  
  48.         private void to_txt_TextChanged(object sender, EventArgs e)
  49.         {
  50.            //ftp.To = to_txt.Text;
  51.         }
  52.  
  53.         private void submit_btn_Click(object sender, EventArgs e)
  54.         {
  55.             Configuration config = ConfigurationManager.OpenExeConfiguration(ConfigurationUserLevel.None);
  56.  
  57.             config.AppSettings.Settings["starttime"].Value = starttime_dtp.Text;
  58.             config.AppSettings.Settings["endtime"].Value = endtime_dtp.Text;
  59.             config.AppSettings.Settings["from"].Value = frm_txt.Text;
  60.             config.AppSettings.Settings["to"].Value = to_txt.Text;
  61.  
  62.             config.Save(ConfigurationSaveMode.Modified);
  63.  
  64.             ConfigurationManager.RefreshSection("appSettings");
  65.  
  66.  
  67.  
  68.         }
  69.  
pls can anyone give coding for this task?
Oct 17 '11 #1
0 1519

Sign in to post your reply or Sign up for a free account.

Similar topics

1
by: Vlad | last post by:
Is there any way to install multiple instances of the same windows service designed with VS.NET 2003? I tried copying the binaries into a separate folder and then copying registry entries for the...
4
by: Felipe Garcia | last post by:
I've built a windows service, but this service has it's environment (assemblies, config files) in a folder like c:\myservice\includes. But everytime that i need to load a file, the service always...
0
by: patricia | last post by:
Hi all, I got a problem with my web application. I have a project under the inetpub/wwwroot. Now I move it to another folder under c:\. There is a subfolder in this project. when I run the web...
9
by: Mondal | last post by:
Hi, Can anybody tell me how to develop Windows Services (which are actually daemons) using Python. Also what protocol is most suitable for developing a server-client application with the server...
8
by: vtxr1300 | last post by:
I've followed 2 very similar tutorials on creating a windows service and an installer. But, after successfully compiling it, I try to do the InstallUtil command, but I get a...
10
by: dermot | last post by:
I have wrriten a small windows service application in visual studio ..net 2003 which listens for incoming FTP files. These files would overwrite over time due to duplicate file names. However any...
4
by: ags5406 | last post by:
Hi All I have a task that I'm thinking about attacking in two different ways but don't know enough about Windows Services. First: We have a server application written in VB.net that acts as...
3
by: jaeden99 | last post by:
I was wandering if nyone has a script to move files older than x days old? i've seen several to delete, but I don't want to delete. I would like to create a backup of the files first verify with...
2
by: Jim in Arizona | last post by:
I made up a service that will move files from a folder on the machine that the service is running to a share on another machine. I use a try/catch incase an error is thrown and write that error to...
5
by: =?Utf-8?B?dmlzaHJ1dGg=?= | last post by:
This code works fine in Windows Application. In Windows Application, I am able to zip the image files properly and it totally contains 900MB My problem is the same code which I used in my Windows...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.