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. File system object

File system object

Scheduled Pinned Locked Moved ASP.NET
designquestion
2 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.
  • S Offline
    S Offline
    soorma
    wrote on last edited by
    #1

    I have a text file and i want to Split the file into mulitple files based off the city and then create new files with the city name. I am able to read the file and also chnaged the semi colon to a comma in the file. How do i split into multiple files based on city and then create new ones based upon city names This is how the text file looks like(just a junk data) FirstName;LastName;DOB;City;State;Zip Suzy;Adams;05/15/1977;Salt Lake City;UT;84054 Brady;Broom;03/16/1978;Provo;UT;84054 Andrew;Packard;02/06/1980;Salt Lake City;UT;84034 Ralph;Vunderly;01/15/1983;Provo;UT;84023 Thi si my code looks like Imports System Imports System.IO Imports System.Collections Partial Class _Default Inherits System.Web.UI.Page Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load Dim objReader As New StreamReader("c:\test.txt") Dim sLine As String = "" Dim arrText As New ArrayList() Do sLine = objReader.ReadLine() If Not sLine Is Nothing Then sLine = Replace(sLine, ";", ",") arrText.Add(sLine) End If Loop Until sLine Is Nothing objReader.Close() For Each sLine In arrText ' Console.WriteLine(sLine) ' MsgBox(sLine) 'Response.Write(sLine) Dim furst As String = arrText(0) Response.Write(furst) Next 'Response.Write(sLine) Response.Write(furst) Console.ReadLine() End Sub End Class

    E 1 Reply Last reply
    0
    • S soorma

      I have a text file and i want to Split the file into mulitple files based off the city and then create new files with the city name. I am able to read the file and also chnaged the semi colon to a comma in the file. How do i split into multiple files based on city and then create new ones based upon city names This is how the text file looks like(just a junk data) FirstName;LastName;DOB;City;State;Zip Suzy;Adams;05/15/1977;Salt Lake City;UT;84054 Brady;Broom;03/16/1978;Provo;UT;84054 Andrew;Packard;02/06/1980;Salt Lake City;UT;84034 Ralph;Vunderly;01/15/1983;Provo;UT;84023 Thi si my code looks like Imports System Imports System.IO Imports System.Collections Partial Class _Default Inherits System.Web.UI.Page Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load Dim objReader As New StreamReader("c:\test.txt") Dim sLine As String = "" Dim arrText As New ArrayList() Do sLine = objReader.ReadLine() If Not sLine Is Nothing Then sLine = Replace(sLine, ";", ",") arrText.Add(sLine) End If Loop Until sLine Is Nothing objReader.Close() For Each sLine In arrText ' Console.WriteLine(sLine) ' MsgBox(sLine) 'Response.Write(sLine) Dim furst As String = arrText(0) Response.Write(furst) Next 'Response.Write(sLine) Response.Write(furst) Console.ReadLine() End Sub End Class

      E Offline
      E Offline
      Expert Coming
      wrote on last edited by
      #2

      Create the new file, write data to it, save it. Rinse and repeat until you are done. You can find plenty of sample code on how to do this on Google, just search file handling or files. One trick with ASP.NET though, you have to give IUSR_[Machine Name] access to the folder you want to read/write files to.

      The best way to accelerate a Macintosh is at 9.8m/sec² - Marcus Dolengo

      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