Solved

windows service to move file after read

Posted on 2014-02-19
3
478 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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Many of us here at EE write code. Many of us write exceptional code; just as many of us write exception-prone code. As we all should know, exceptions are a mechanism for handling errors which are typically out of our control. From database errors, t…
This article shows how to deploy dynamic backgrounds to computers depending on the aspect ratio of display
This video shows how to remove a single email address from the Outlook 2010 Auto Suggestion memory. NOTE: For Outlook 2016 and 2013 perform the exact same steps. Open a new email: Click the New email button in Outlook. Start typing the address: …
You have products, that come in variants and want to set different prices for them? Watch this micro tutorial that describes how to configure prices for Magento super attributes. Assigning simple products to configurable: We assigned simple products…

948 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

Need Help in Real-Time?

Connect with top rated Experts

20 Experts available now in Live!

Get 1:1 Help Now