Advertisement

11.12.2007 at 05:35PM PST, ID: 22956149
[x]
Attachment Details

Help....        Must Maintain Directory and Files LastAccessedTime

Asked by BillyDvD in C# Programming Language, .NET, .NET Framework 2.0

Tags: C#

I have to search thru massive directory trees including all files within. I have one issue using the (Directory | DirectoryInfo | DirectoryInfo[] and the File | FileInfo | FileInfo[] )
They all mod the LastAccessedTime !!!! ANd the only property I need happens to this....  So if I look at it today and it was 10/5/1999 right after I look at it, it becomes DateTime.Now !! Grrrrrrr :)

I am probably overlopoking something simplistic but as it stands I need help fast....   Thanks in advance BillyDvd



=========================   SAMPLE CODE ONLY ==========================
class Class1
    {
        MoreMethods DI = new MoreMethods();
        List<FileInfos> ListToCompress = new List<FileInfos>();
        DirectoryInfo RootDir = new DirectoryInfo( Variables.Root );
        DirectoryInfo[ ] ROOT;

        private void BtnGetDirectories_Click( object sender , EventArgs e )
        {
            ListToCompress = new List<FileInfos>();

            ROOT = RootDir.GetDirectories( "*" , SearchOption.TopDirectoryOnly );

            foreach ( DirectoryInfo var in ROOT )
            {
                if ( DI.AddToList( var ) )
                    ListToCompress.Add( new FileInfos( var.FullName , var.LastAccessTime , var ) );
            }

            foreach ( FileInfos var in ListToCompress )
            {
                Console.WriteLine( var.Parent.ToString() + "\t" + var.LastAccessTime.ToString() + "\r\n" );
            }

        }



        /// <summary>
        /// Hold the relevant info for the list items
        /// </summary>
        internal class FileInfos
        {
            public DirectoryInfo Parent;
            public string FullName;
            public DateTime LastAccessedTime;

            /// <summary>
            /// Initializes a new instance of the <see cref="FileInfos"/> class.
            /// </summary>
            /// <param name="FullName">The full name.</param>
            /// <param name="LastAccessedTime">The last accessed time.</param>
            /// <param name="Parent">The parent.</param>
            public FileInfos( string FullName , DateTime LastAccessedTime , DirectoryInfo Parent )
            {
                this.FullName = FullName;
                this.LastAccessedTime = LastAccessedTime;
                this.Parent = Parent;
            }

        }

        internal class MoreMethods
        {
            /// <summary>
            /// Returns True if the item should be added to the list
            /// </summary>
            /// <param name="FileInfoArray"></param>
            /// <returns></returns>
            bool AddToList( FileInfo[ ] FileInfoArray )
            {
                if ( FileInfoArray.Length == 0 )
                    return false;

                List<FileInfo> Addthesefiles = new List<FileInfo>( FileInfoArray );
                //---| Lets see if there are any or all ready to be archived. |---
                Addthesefiles = Addthesefiles.FindAll( IsOlderThan );

                if ( Addthesefiles.Count == FileInfoArray.Length )
                    return true;
                else
                    return false;
            }

            public bool AddToList( DirectoryInfo di )
            {
                DirectoryInfo[ ] da = di.GetDirectories( "*" , SearchOption.AllDirectories );
                if ( da.Length > 0 )
                {
                    foreach ( DirectoryInfo var in da )
                    {
                        if ( !AddToList( var.GetFiles( "*" , SearchOption.AllDirectories ) ) )
                            return false;
                    }
                    return true;
                }

                return AddToList( di.GetFiles( "*" , SearchOption.AllDirectories ) );

            }
        }

    }Start Free Trial
 
Loading Advertisement...
 
[+][-]11.12.2007 at 07:24PM PST, ID: 20269305

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 7-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]11.12.2007 at 07:26PM PST, ID: 20269314

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 7-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]11.12.2007 at 08:13PM PST, ID: 20269481

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 7-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]11.13.2007 at 07:27AM PST, ID: 20272108

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 7-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]11.13.2007 at 08:35AM PST, ID: 20272762

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 7-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]11.13.2007 at 11:20AM PST, ID: 20274179

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 7-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]11.14.2007 at 12:04PM PST, ID: 20283220

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 7-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]11.14.2007 at 12:25PM PST, ID: 20283427

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 7-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]11.14.2007 at 01:09PM PST, ID: 20283863

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 7-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]11.14.2007 at 01:20PM PST, ID: 20283973

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 7-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]11.14.2007 at 01:22PM PST, ID: 20283999

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 7-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]11.14.2007 at 03:56PM PST, ID: 20285164

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 7-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]11.16.2007 at 04:34AM PST, ID: 20297680

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 7-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]11.16.2007 at 04:49AM PST, ID: 20297738

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 7-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]11.16.2007 at 07:50AM PST, ID: 20299093

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 7-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]12.15.2007 at 03:04AM PST, ID: 20476910

Experts Exchange has a courteous staff of administrators who help members get the most out of the website by means of administrative comments like this one.

Start your 7-day free trial to view this Administrative Comment or ask the Experts your question.

 
[+][-]12.17.2007 at 12:34AM PST, ID: 20483511

View this solution now by starting your 7-day free trial. Setting up your free trial is quick, easy, and secure. We will return you to this solution, unlocked, when you're done.

 

About this solution

Zones: C# Programming Language, .NET, .NET Framework 2.0
Tags: C#
Sign Up Now!
Solution Provided By: Jerry_Pang
Participating Experts: 4
Solution Grade: A
 
 
[+][-]12.17.2007 at 12:40AM PST, ID: 20483528

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 7-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]12.22.2007 at 07:45PM PST, ID: 20520454

Experts Exchange has a courteous staff of administrators who help members get the most out of the website by means of administrative comments like this one.

Start your 7-day free trial to view this Administrative Comment or ask the Experts your question.

 
[+][-]01.01.2008 at 07:22AM PST, ID: 20560038

Experts Exchange has a courteous staff of administrators who help members get the most out of the website by means of administrative comments like this one.

Start your 7-day free trial to view this Administrative Comment or ask the Experts your question.

 
 
Loading Advertisement...
20080716-EE-VQP-32 / EE_QW_2_20070628