Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. Web Development
  3. ASP.NET
  4. FSO read in?

FSO read in?

Scheduled Pinned Locked Moved ASP.NET
questionhelp
5 Posts 2 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • L Offline
    L Offline
    Larsson
    wrote on last edited by
    #1

    Hello, I have a big problem. I need to loop every file in the folder for *.gif image. I dont now there namnes. When I have find a image file I need to read in a *.txt with the same name exept for the *.txt. Now to the problem I have a loop that find the *.gif image and now I want to read in the text in the text file with the same namn but it is a *.txt how can I do that. If someone have any exemple it should be create. Thank.

    G 1 Reply Last reply
    0
    • L Larsson

      Hello, I have a big problem. I need to loop every file in the folder for *.gif image. I dont now there namnes. When I have find a image file I need to read in a *.txt with the same name exept for the *.txt. Now to the problem I have a loop that find the *.gif image and now I want to read in the text in the text file with the same namn but it is a *.txt how can I do that. If someone have any exemple it should be create. Thank.

      G Offline
      G Offline
      Gavin Jeffrey
      wrote on last edited by
      #2

      i would do something like - foreach (string s in System.IO.Directory.GetFiles(@"c:\dir", "*.gif")) { string txtPath = s.Substring(0, s.Length - 3) + "txt"; System.IO.TextReader tr = new System.IO.StreamReader(txtPath); string text = tr.ReadToEnd(); tr.Close(); }

      L 2 Replies Last reply
      0
      • G Gavin Jeffrey

        i would do something like - foreach (string s in System.IO.Directory.GetFiles(@"c:\dir", "*.gif")) { string txtPath = s.Substring(0, s.Length - 3) + "txt"; System.IO.TextReader tr = new System.IO.StreamReader(txtPath); string text = tr.ReadToEnd(); tr.Close(); }

        L Offline
        L Offline
        Larsson
        wrote on last edited by
        #3

        Thank!

        1 Reply Last reply
        0
        • G Gavin Jeffrey

          i would do something like - foreach (string s in System.IO.Directory.GetFiles(@"c:\dir", "*.gif")) { string txtPath = s.Substring(0, s.Length - 3) + "txt"; System.IO.TextReader tr = new System.IO.StreamReader(txtPath); string text = tr.ReadToEnd(); tr.Close(); }

          L Offline
          L Offline
          Larsson
          wrote on last edited by
          #4

          Well this is the code I have! <% Set fso = CreateObject("Scripting.FileSystemObject") Set f = fso.GetFolder(Server.MapPath("/test/")) Set fc = f.Files For Each f1 in fc if right(lcase(f1.name),4) = ".gif" then Response.Write("


          ") Next %> And in this code I need to read in the text file so the image is ahown and then the text. How do I do that with the code you give me?

          G 1 Reply Last reply
          0
          • L Larsson

            Well this is the code I have! <% Set fso = CreateObject("Scripting.FileSystemObject") Set f = fso.GetFolder(Server.MapPath("/test/")) Set fc = f.Files For Each f1 in fc if right(lcase(f1.name),4) = ".gif" then Response.Write("


            ") Next %> And in this code I need to read in the text file so the image is ahown and then the text. How do I do that with the code you give me?

            G Offline
            G Offline
            Gavin Jeffrey
            wrote on last edited by
            #5

            are you using asp.net or asp 3? cause the code i have given you will only work in asp.net. if you wanted to do this in asp 3 you would have to have do something like: 'get the file path - Set txtFilePath = Replace(f1.name, right(lcase(f1.name),4), ".txt") 'then read the file using fso dim txtStream Set txtStream = fso.OpenTextFile(txtFilePath, fsoForReading) 'the write the string out Response.Write txtStream.ReadAll txtStream.Close im a bit rusty in this area but this should give you more or less an idea!

            1 Reply Last reply
            0
            Reply
            • Reply as topic
            Log in to reply
            • Oldest to Newest
            • Newest to Oldest
            • Most Votes


            • Login

            • Don't have an account? Register

            • Login or register to search.
            • First post
              Last post
            0
            • Categories
            • Recent
            • Tags
            • Popular
            • World
            • Users
            • Groups