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 can i create a file in a directory ?

how can i create a file in a directory ?

Scheduled Pinned Locked Moved Visual Basic
question
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.
  • M Offline
    M Offline
    Mohammed Amine
    wrote on last edited by
    #1

    Hi everybody Please can you tell me the methode allows to check if a file is existing in a directory "X" if it is then its ok if not i want to create it with some statements in please if you know write me the code & explain as much as you can thank you :) try to be good if you can't be the best

    N 1 Reply Last reply
    0
    • M Mohammed Amine

      Hi everybody Please can you tell me the methode allows to check if a file is existing in a directory "X" if it is then its ok if not i want to create it with some statements in please if you know write me the code & explain as much as you can thank you :) try to be good if you can't be the best

      N Offline
      N Offline
      nobel tele gl
      wrote on last edited by
      #2

      You could do something like this example

      Dim fs As System.IO.FileStream
      Dim scrFile As System.IO.StreamWriter

      strFileName = "some path and filename"

      If Not IO.File.Exists(strFileName) Then
      fs = New System.IO.FileStream(strFileName, IO.FileMode.OpenOrCreate, IO.FileAccess.Write)
      else
      'Just open file here
      Endif

      code is posted "as is" an is just an example. You could check out the IO namespace http://msdn2.microsoft.com/en-us/library/system.io.aspx[^] http://msdn2.microsoft.com/en-us/library/system.io.filestream.aspx[^] this will properly give you a good idea which statements you need It's my opinion that nothing is impossible, it's "just" at matter of enough knowledge, time and money.

      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