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. General Programming
  3. Visual Basic
  4. How to Change the default location of file --- VB.NET

How to Change the default location of file --- VB.NET

Scheduled Pinned Locked Moved Visual Basic
visual-studiocsharpsysadmintutorial
4 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.
  • M Offline
    M Offline
    mominafiz
    wrote on last edited by
    #1

    I am making a VB.NET web application in VS.NET 2008. I am using streamwriter to write in the file. I am using filestream to create a new file Dim fs As New FileStream("'" & FN & "'.txt", FileMode.CreateNew, FileAccess.Write) using above line create the file in the default directory i.e (C:\Program Files\Microsoft Visual Studio 9.0\Common7\IDE) But i want to store my files in my defined directory say ("C:/HMSFiles/PPFiles/") how to replace the default directory with defined directory?? how to read the file from the defined directory? if i want to store these files on the server how to do this?? Here is the code:

    Dim FilePath As String = ("C:/HMSfiles/PPFiles/")

    Dim fs As New FileStream("'" & FN & "'.txt", FileMode.CreateNew, FileAccess.Write)
    Dim s As New StreamWriter(fs)
    pretestcatch = pretestTA.Text
    posttestcatch = posttestTA.Text

    s.WriteLine("PRE TEST PRECAUTIONS:")
    s.NewLine = ""
    s.Write(pretestcatch)

    s.WriteLine("POST TEST PRECAUTIONS:")
    s.NewLine = ""
    s.Write(posttestcatch)
    s.Close()

    J 1 Reply Last reply
    0
    • M mominafiz

      I am making a VB.NET web application in VS.NET 2008. I am using streamwriter to write in the file. I am using filestream to create a new file Dim fs As New FileStream("'" & FN & "'.txt", FileMode.CreateNew, FileAccess.Write) using above line create the file in the default directory i.e (C:\Program Files\Microsoft Visual Studio 9.0\Common7\IDE) But i want to store my files in my defined directory say ("C:/HMSFiles/PPFiles/") how to replace the default directory with defined directory?? how to read the file from the defined directory? if i want to store these files on the server how to do this?? Here is the code:

      Dim FilePath As String = ("C:/HMSfiles/PPFiles/")

      Dim fs As New FileStream("'" & FN & "'.txt", FileMode.CreateNew, FileAccess.Write)
      Dim s As New StreamWriter(fs)
      pretestcatch = pretestTA.Text
      posttestcatch = posttestTA.Text

      s.WriteLine("PRE TEST PRECAUTIONS:")
      s.NewLine = ""
      s.Write(pretestcatch)

      s.WriteLine("POST TEST PRECAUTIONS:")
      s.NewLine = ""
      s.Write(posttestcatch)
      s.Close()

      J Offline
      J Offline
      Johnny J
      wrote on last edited by
      #2

      Try

      Dim fs As New FileStream(FilePath & "'" & FN & "'.txt", FileMode.CreateNew, FileAccess.Write)

      M 1 Reply Last reply
      0
      • J Johnny J

        Try

        Dim fs As New FileStream(FilePath & "'" & FN & "'.txt", FileMode.CreateNew, FileAccess.Write)

        M Offline
        M Offline
        mominafiz
        wrote on last edited by
        #3

        thanks Johnny. after posting i realized how to do it...but can u tell me how to save the file on server without using fileupload control in asp.net .....i want to store the content in textbox directly in file on server. and how to retrieve the file from the server. thanks

        J 1 Reply Last reply
        0
        • M mominafiz

          thanks Johnny. after posting i realized how to do it...but can u tell me how to save the file on server without using fileupload control in asp.net .....i want to store the content in textbox directly in file on server. and how to retrieve the file from the server. thanks

          J Offline
          J Offline
          Johnny J
          wrote on last edited by
          #4

          The exact same way. You use streamwriters and streamreaders to create and read the files.

          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