Click here to Skip to main content
15,891,033 members
Home / Discussions / C#
   

C#

 
QuestionHow to compile more then one project in same time ? Pin
Yanshof4-Dec-07 11:56
Yanshof4-Dec-07 11:56 
AnswerRe: How to compile more then one project in same time ? Pin
Dave Kreskowiak4-Dec-07 14:34
mveDave Kreskowiak4-Dec-07 14:34 
QuestionListView: set "BackColor" in a SubItem Pin
Patricio Tapia4-Dec-07 10:51
Patricio Tapia4-Dec-07 10:51 
GeneralRe: ListView: set "BackColor" in a SubItem Pin
Insincere Dave4-Dec-07 11:32
Insincere Dave4-Dec-07 11:32 
QuestionListView: set "BackColor" in a SubItem Pin
Patricio Tapia4-Dec-07 10:50
Patricio Tapia4-Dec-07 10:50 
GeneralRe: ListView: set "BackColor" in a SubItem Pin
Skippums4-Dec-07 11:48
Skippums4-Dec-07 11:48 
GeneralRe: ListView: set "BackColor" in a SubItem Pin
Vasudevan Deepak Kumar4-Dec-07 18:04
Vasudevan Deepak Kumar4-Dec-07 18:04 
Generalhelp me!!! Pin
Shani Aulakh4-Dec-07 10:36
Shani Aulakh4-Dec-07 10:36 
I have the following FolderWatcher.cs class that monitors and deletes fies older than X number of days.

using System;<br />
using System.IO;<br />
using System.Collections;<br />
using System.Text;<br />
<br />
namespace Files_ExtLib1<br />
{<br />
    public class FolderWatcher<br />
    {<br />
        string m_FolderPath;<br />
<br />
        public FolderWatcher()<br />
        {<br />
            //<br />
            // TODO: Add constructor logic here<br />
            //<br />
        }<br />
<br />
        #region Property<br />
        public string FolderPath<br />
        {<br />
            get<br />
            {<br />
                return m_FolderPath;<br />
            }<br />
            set<br />
            {<br />
                m_FolderPath = value;<br />
            }<br />
        }<br />
        #endregion<br />
<br />
        /// <summary><br />
        /// Deletes the files older the days, hours, and<br />
        /// minutes specified<br />
        /// </summary><br />
        /// <param name="Days"></param><br />
        /// <param name="Hrs"></param><br />
        /// <param name="Mins"></param><br />
        /// <returns>Number of files deleted</returns><br />
        public int DeleteFilesOlderThan(int Days, int Hrs, int Mins)<br />
        {<br />
            string[] oldFilePaths = FilesOlderThan(Days, Hrs, Mins);<br />
            int count = 0;<br />
            foreach (string filePath in oldFilePaths)<br />
            {<br />
                try<br />
                {<br />
                    File.Delete(filePath);<br />
                    count++;<br />
                }<br />
                catch (Exception e)<br />
                {<br />
                    Console.WriteLine("Unable to delete " + filePath);<br />
                    Console.WriteLine("Reason: {0}", e);<br />
                    //Console.WriteLine("Detected an exception!!!\n" + e );<br />
                }<br />
                Console.WriteLine("Files successfully deleted");<br />
            }<br />
            // presumably number of files deleted to be returned<br />
            return count;<br />
        }<br />
<br />
<br />
        /// <summary><br />
        /// Reurns filenames having last modified time older than<br />
        /// specified period.<br />
        /// </summary><br />
        /// <param name="Days"></param><br />
        /// <param name="Hrs"></param><br />
        /// <param name="Mins"></param><br />
        /// <returns></returns><br />
        public string[] FilesOlderThan(int Days, int Hrs, int Mins)<br />
        {<br />
            TimeSpan ts = new TimeSpan(Days, Hrs, Mins, 0);<br />
            ArrayList oldFilePaths = new ArrayList();<br />
            // FolderPath is assumed to be path being watched<br />
            string[] filePaths = Directory.GetFiles(FolderPath);<br />
            DateTime currentDate = DateTime.Now;<br />
            foreach (string filePath in filePaths)<br />
            {<br />
                DateTime lastWriteDate = File.GetLastWriteTime(filePath);<br />
                if ((currentDate - lastWriteDate) > ts)<br />
                {<br />
                    oldFilePaths.Add(filePath);<br />
                }<br />
            }<br />
            return (string[])oldFilePaths.ToArray(typeof(string));  <br />
        }<br />
    }<br />
}


I need to test this peice of code on a dummy foler. I already did it buh I want to add 2 more methods.
1) method that will create dummy test files for me with format .txt, .exe, .log
2) secondly, to test my class, i want a method that will delete specific file types. e.g delete .txt files only or .exe, or .log

Anybodyy can help me with this?
Thanks alot
Generalsimulating e-mail between project's forms Pin
Genius.Boy4-Dec-07 10:34
Genius.Boy4-Dec-07 10:34 
GeneralperformClick doesn't work Pin
gizmokaka4-Dec-07 10:24
gizmokaka4-Dec-07 10:24 
GeneralRe: performClick doesn't work Pin
Dave Kreskowiak4-Dec-07 10:46
mveDave Kreskowiak4-Dec-07 10:46 
GeneralRe: performClick doesn't work Pin
gizmokaka4-Dec-07 11:19
gizmokaka4-Dec-07 11:19 
General'The Binding Handle Is Invalid' error Pin
Lutosław4-Dec-07 9:41
Lutosław4-Dec-07 9:41 
GeneralApp_Code folder not found Pin
ss.mmm4-Dec-07 8:46
ss.mmm4-Dec-07 8:46 
GeneralRe: App_Code folder not found Pin
pmarfleet4-Dec-07 9:26
pmarfleet4-Dec-07 9:26 
QuestionHow to kill a process running on network machine using c# Pin
mevivekdua4-Dec-07 8:05
mevivekdua4-Dec-07 8:05 
GeneralRe: How to kill a process running on network machine using c# Pin
Dave Kreskowiak4-Dec-07 10:41
mveDave Kreskowiak4-Dec-07 10:41 
GeneralRe: How to kill a process running on network machine using c# Pin
mevivekdua4-Dec-07 22:33
mevivekdua4-Dec-07 22:33 
GeneralRe: How to kill a process running on network machine using c# Pin
mevivekdua5-Dec-07 8:38
mevivekdua5-Dec-07 8:38 
GeneralNon-standard UI Pin
Google Ninja4-Dec-07 7:54
Google Ninja4-Dec-07 7:54 
GeneralRe: Non-standard UI Pin
Anthony Mushrow4-Dec-07 8:49
professionalAnthony Mushrow4-Dec-07 8:49 
Questionhelp for newbe Pin
dxladner4-Dec-07 7:24
dxladner4-Dec-07 7:24 
GeneralRe: help for newbe Pin
Dave Kreskowiak4-Dec-07 7:45
mveDave Kreskowiak4-Dec-07 7:45 
GeneralRe: help for newbe Pin
dxladner4-Dec-07 7:55
dxladner4-Dec-07 7:55 
GeneralRe: help for newbe Pin
ChrisKo4-Dec-07 8:03
ChrisKo4-Dec-07 8:03 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.