File Structure

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Peter

    File Structure

    Hi
    I'm looking for a way to extract a file name and file create date and then
    replace them after modifying them.
    I'd be grateful for any help.


    Peter
    To err is human but it takes a computer to really mess things up!


  • James L Hill

    #2
    Re: File Structure

    Use the FileSystemObjec t to gain access to files and their properties.

    Dim objFSO As New FileSystemObjec t
    Dim objFolder As Folder
    Dim objFile As File
    Set objFolder = objFSO.GetFolde r(sFilePath)
    For Each objFile In objFolder.Files
    sFileName = objFile.Name
    dCreateDate = objFile.DateCre ated
    dModifiedDate = objFile.Modifie dDate
    Next

    NOTE: The file dates are read-only properties.


    "Peter" <gammaNO@SPAMbl ueyonder.co.uk> wrote in message
    news:w47Md.206$ 89.159@fe3.news .blueyonder.co. uk...[color=blue]
    > Hi
    > I'm looking for a way to extract a file name and file create date and then
    > replace them after modifying them.
    > I'd be grateful for any help.
    >
    >
    > Peter
    > To err is human but it takes a computer to really mess things up!
    >
    >[/color]


    Comment

    • Peter

      #3
      Re: File Structure

      Many thanks, I'll start playing when I get a minute.
      Pity about the dates - is there any way to modify these?

      Peter
      To err is human but it takes a computer to really mess things up!

      "James L Hill" <james.hill83@v erizon.net> wrote in message
      news:gkCMd.6364 $Dc.5137@trnddc 06...[color=blue]
      > Use the FileSystemObjec t to gain access to files and their properties.
      >
      > Dim objFSO As New FileSystemObjec t
      > Dim objFolder As Folder
      > Dim objFile As File
      > Set objFolder = objFSO.GetFolde r(sFilePath)
      > For Each objFile In objFolder.Files
      > sFileName = objFile.Name
      > dCreateDate = objFile.DateCre ated
      > dModifiedDate = objFile.Modifie dDate
      > Next
      >
      > NOTE: The file dates are read-only properties.
      >
      >
      > "Peter" <gammaNO@SPAMbl ueyonder.co.uk> wrote in message
      > news:w47Md.206$ 89.159@fe3.news .blueyonder.co. uk...[color=green]
      >> Hi
      >> I'm looking for a way to extract a file name and file create date and
      >> then
      >> replace them after modifying them.
      >> I'd be grateful for any help.
      >>
      >>
      >> Peter
      >> To err is human but it takes a computer to really mess things up!
      >>
      >>[/color]
      >
      >[/color]


      Comment

      • Rick Rothstein

        #4
        Re: File Structure

        > Pity about the dates - is there any way to modify these?

        VBnet provides Intermediate and Advanced Win32 API code for VB developers. Comprehensive Code, FAQ, Developers Resources & News, alphabetical API/Type/Constant/Method Index, along with the largest Visual Basic-related links list on the net.


        Rick - MVP

        Comment

        • Peter

          #5
          Re: File Structure

          Many thanks (I think!).
          As a dabbler in Vb (but not in programming, I wrote my first program back in
          1968 in a nice air conditioned room!)
          I can see I'm going to have some fun.

          Peter

          "Rick Rothstein" <rickNOSPAMnews @NOSPAMcomcast. net> wrote in message
          news:Xo6dnVUNRu VO557fRVn-rg@comcast.com. ..[color=blue][color=green]
          >> Pity about the dates - is there any way to modify these?[/color]
          >
          > http://vbnet.mvps.org/code/fileapi/filedatetime.htm
          >
          > Rick - MVP[/color]


          Comment

          • Rick Rothstein

            #6
            Re: File Structure

            > Many thanks (I think!).[color=blue]
            > As a dabbler in Vb (but not in programming, I wrote my first program[/color]
            back in[color=blue]
            > 1968 in a nice air conditioned room!)
            > I can see I'm going to have some fun.[/color]

            Sorry for the ugliness of the API solution I referred you to; however,
            as James pointed out, VB does not have direct write access to the dates,
            so the only solution is to use API functions.

            Rick - MVP

            Comment

            • Peter

              #7
              Re: File Structure

              No problem. It will force me to get to grips with API.
              Another question has occurred to me now. I can see how to display a list of
              folders and select one. Can I access the contents so that I can get all the
              file names in an array?

              Sorry about all the individual questions

              Peter

              "Rick Rothstein" <rickNOSPAMnews @NOSPAMcomcast. net> wrote in message
              news:8_qdnbk8Zt OzJJ7fRVn-pw@comcast.com. ..[color=blue][color=green]
              >> Many thanks (I think!).
              >> As a dabbler in Vb (but not in programming, I wrote my first program[/color]
              > back in[color=green]
              >> 1968 in a nice air conditioned room!)
              >> I can see I'm going to have some fun.[/color]
              >
              > Sorry for the ugliness of the API solution I referred you to; however,
              > as James pointed out, VB does not have direct write access to the dates,
              > so the only solution is to use API functions.
              >
              > Rick - MVP
              >[/color]


              Comment

              • Spanner

                #8
                Re: File Structure


                Set objFSO = CreateObject("S cripting.FileSy stemObject")
                strFolder = "C:\Temp"

                Set objFolder = objFSO.GetFolde r(strFolder)
                Set objFiles = objFolder.Files

                For Each objFile in objFiles
                MsgBox objFile.Name
                Next


                Peter wrote:[color=blue]
                > No problem. It will force me to get to grips with API.
                > Another question has occurred to me now. I can see how to display a list of
                > folders and select one. Can I access the contents so that I can get all the
                > file names in an array?
                >
                > Sorry about all the individual questions
                >
                > Peter
                >
                > "Rick Rothstein" <rickNOSPAMnews @NOSPAMcomcast. net> wrote in message
                > news:8_qdnbk8Zt OzJJ7fRVn-pw@comcast.com. ..
                >[color=green][color=darkred]
                >>>Many thanks (I think!).
                >>>As a dabbler in Vb (but not in programming, I wrote my first program[/color]
                >>
                >>back in
                >>[color=darkred]
                >>>1968 in a nice air conditioned room!)
                >>>I can see I'm going to have some fun.[/color]
                >>
                >>Sorry for the ugliness of the API solution I referred you to; however,
                >>as James pointed out, VB does not have direct write access to the dates,
                >>so the only solution is to use API functions.
                >>
                >>Rick - MVP
                >>[/color]
                >
                >
                >[/color]

                Comment

                • Peter

                  #9
                  Re: File Structure

                  Thanks

                  Peter

                  "Spanner" <no.email@no.em ail.com> wrote in message
                  news:hziPd.1578 24$K7.125840@ne ws-server.bigpond. net.au...[color=blue]
                  >
                  > Set objFSO = CreateObject("S cripting.FileSy stemObject")
                  > strFolder = "C:\Temp"
                  >
                  > Set objFolder = objFSO.GetFolde r(strFolder)
                  > Set objFiles = objFolder.Files
                  >
                  > For Each objFile in objFiles
                  > MsgBox objFile.Name
                  > Next
                  >
                  >
                  > Peter wrote:[color=green]
                  >> No problem. It will force me to get to grips with API.
                  >> Another question has occurred to me now. I can see how to display a list
                  >> of folders and select one. Can I access the contents so that I can get
                  >> all the file names in an array?
                  >>
                  >> Sorry about all the individual questions
                  >>
                  >> Peter
                  >>
                  >> "Rick Rothstein" <rickNOSPAMnews @NOSPAMcomcast. net> wrote in message
                  >> news:8_qdnbk8Zt OzJJ7fRVn-pw@comcast.com. ..
                  >>[color=darkred]
                  >>>>Many thanks (I think!).
                  >>>>As a dabbler in Vb (but not in programming, I wrote my first program
                  >>>
                  >>>back in
                  >>>
                  >>>>1968 in a nice air conditioned room!)
                  >>>>I can see I'm going to have some fun.
                  >>>
                  >>>Sorry for the ugliness of the API solution I referred you to; however,
                  >>>as James pointed out, VB does not have direct write access to the dates,
                  >>>so the only solution is to use API functions.
                  >>>
                  >>>Rick - MVP
                  >>>[/color]
                  >>
                  >>[/color][/color]

                  Comment

                  Working...