Solved

windows service to move file after read

Posted on 2014-02-19
3
481 Views
Last Modified: 2014-02-25
I am having two folder A,B.

Folder A Kept one XML file,i have to read that xml file and insert the corresponding
data in to database ,after that  Moved that file to Folder B.
it will be done in
every 5 minutes through widows service.

Could you please provide the code for the same.
0
Comment
Question by:nicemanish
3 Comments
 
LVL 15

Assisted Solution

by:Minh Võ Công
Minh Võ Công earned 250 total points
ID: 39872265
string filename =  "test.txt";
string sourceFolder = @"C:\Users\Public\public\";
 string destinationFolder = @"C:\Users\Public\private\";

        // To move a file or folder to a new location:
        System.IO.File.Move(sourceFolder + filename  , destinationFolder  + filename );

        // To move an entire directory. To programmatically modify or combine
        // path strings, use the System.IO.Path class.
        System.IO.Directory.Move(@"C:\Users\Public\public\test\", @"C:\Users\Public\private");

code sample:
http://msdn.microsoft.com/en-us/library/cc148994.aspx
0
 
LVL 16

Accepted Solution

by:
Kalpesh Chhatrala earned 250 total points
ID: 39872473
Check below Windows Service Step By Step Tutorial

http://www.codeproject.com/Articles/106742/Creating-a-simple-Windows-Service 

you need to use Timer in Windows Service to execute previous author code every 5 minute.
0
 

Author Closing Comment

by:nicemanish
ID: 39885383
good
0

Featured Post

Courses: Start Training Online With Pros, Today

Brush up on the basics or master the advanced techniques required to earn essential industry certifications, with Courses. Enroll in a course and start learning today. Training topics range from Android App Dev to the Xen Virtualization Platform.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Exception Handling is in the core of any application that is able to dignify its name. In this article, I'll guide you through the process of writing a DRY (Don't Repeat Yourself) Exception Handling mechanism, using Aspect Oriented Programming.
This article shows how to deploy dynamic backgrounds to computers depending on the aspect ratio of display
Although Jacob Bernoulli (1654-1705) has been credited as the creator of "Binomial Distribution Table", Gottfried Leibniz (1646-1716) did his dissertation on the subject in 1666; Leibniz you may recall is the co-inventor of "Calculus" and beat Isaac…
Finds all prime numbers in a range requested and places them in a public primes() array. I've demostrated a template size of 30 (2 * 3 * 5) but larger templates can be built such 210  (2 * 3 * 5 * 7) or 2310  (2 * 3 * 5 * 7 * 11). The larger templa…

808 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question