Get Date Modified of .aspx

asp.net Thailand
  • 12 years ago

    Hi, How can I get the date modified of a certain file [.aspx file]? I'm using ASP.Net and C#.

    Thanks in advance! Smiley Face

  • 12 years ago

    hi Girlkulit,

    what sort of modification you want. Can you elobrate your concern.

    Regards,

    Royal

  • 12 years ago

    Hi, thanks for the time, but I already figured my way out on this.
    My problem (at that time) is I have to get the last modified file in a folder and display in a label the DateTime value. My idea is to get all the files in that particular folder and compare each Date Modified of the files. I use the following codes.

    using System.IO;

    FileInfo objFileInfo;
    DateTime dtLastModified;
    dtLastModified = new DateTime (2001, 1, 1) ;
    foreach (string s in Directory.GetFiles(Server.MapPath("~")))
    {
        objFileInfo = new FileInfo(s);
        if (objFileInfo.LastWriteTime > dtLastModified)
        {
     dtLastModified = objFileInfo.LastWriteTime;
        }
    }
    lblLastModified.Text = dtLastModified.ToString();

    I don't know if I have the correct logic but this simply works for now. Smiley Face
    (Maybe this could be a help to others... ΓΌ)

  • 12 years ago

      //Create a Directory object using DirectoryInfo
                DirectoryInfo dir = new DirectoryInfo(@"C:\cj");
                //Pass the Directory for displaying the contents
                getDirsFiles(dir);
                
               // dataGridView1.DataBindings();

       ////create an array of files using FileInfo object
                //FileInfo[] files;
                ////get all files for the current directory
                //files = d.GetFiles("*.*");
                

                ////iterte through the directory and print the files
                //foreach (FileInfo file in files)
                //{
                    
                //    //get details of each file using file object
                //    String fileName = file.Name;
                //    String fileSize = file.Length.ToString();
                //    String fileExtension = file.Extension;
                //    String fileCreated = file.LastWriteTime.ToString();

                //    DateTime dt = Convert.ToDateTime(fileCreated);
                //    inserrcord(fileName, dt);

                //  }
                

                //get sub-folders for the current directory
    //DirectoryInfo[] dirs = d.GetDirectories("*.*");

Post a reply

Enter your message below

Sign in or Join us (it's free).

Contribute

Why not write for us? Or you could submit an event or a user group in your area. Alternatively just tell us what you think!

Our tools

We've got automatic conversion tools to convert C# to VB.NET, VB.NET to C#. Also you can compress javascript and compress css and generate sql connection strings.

“The trouble with programmers is that you can never tell what a programmer is doing until it's too late.” - Seymour Cray