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 Open A File + Sourabh Das

How To Open A File + Sourabh Das

Scheduled Pinned Locked Moved Visual Basic
tutorial
3 Posts 3 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.
  • D Offline
    D Offline
    Dot Net Jantu
    wrote on last edited by
    #1

    Hi All, I have a text box in which a file path is displayed. A button to click and open the file. Code executes properly but the file dosent open. Here is the Code:

    Private Sub btnOpen_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnOpen.Click
    Try
    strIOPath = ucFile.TxtCode.Text
    If strIOPath = "" Then
    ShowMessage("No File For This Transaction")
    Exit Sub
    End If
    If IO.File.Exists(strIOPath) Then
    File.Open(strIOPath, FileMode.Create)
    Else
    ShowMessage("File Not Found")
    End If
    Catch ex As Exception
    ShowMessage(ex.Message)
    End Try
    End Sub

    Thanks and Regards,

    J L 2 Replies Last reply
    0
    • D Dot Net Jantu

      Hi All, I have a text box in which a file path is displayed. A button to click and open the file. Code executes properly but the file dosent open. Here is the Code:

      Private Sub btnOpen_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnOpen.Click
      Try
      strIOPath = ucFile.TxtCode.Text
      If strIOPath = "" Then
      ShowMessage("No File For This Transaction")
      Exit Sub
      End If
      If IO.File.Exists(strIOPath) Then
      File.Open(strIOPath, FileMode.Create)
      Else
      ShowMessage("File Not Found")
      End If
      Catch ex As Exception
      ShowMessage(ex.Message)
      End Try
      End Sub

      Thanks and Regards,

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

      hi File.Open(strIOPath, FileMode.Create) FileMode.Create = Specifies that the operating system should create a new file. If the file already exists, it will be overwritten. try with FileMode.Open regards

      1 Reply Last reply
      0
      • D Dot Net Jantu

        Hi All, I have a text box in which a file path is displayed. A button to click and open the file. Code executes properly but the file dosent open. Here is the Code:

        Private Sub btnOpen_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnOpen.Click
        Try
        strIOPath = ucFile.TxtCode.Text
        If strIOPath = "" Then
        ShowMessage("No File For This Transaction")
        Exit Sub
        End If
        If IO.File.Exists(strIOPath) Then
        File.Open(strIOPath, FileMode.Create)
        Else
        ShowMessage("File Not Found")
        End If
        Catch ex As Exception
        ShowMessage(ex.Message)
        End Try
        End Sub

        Thanks and Regards,

        L Offline
        L Offline
        Luc Pattyn
        wrote on last edited by
        #3

        hi, if File.Open does not do what you expect, then maybe your expectations are incorrect. Go and check the documentation. That is what it is for. :)

        Luc Pattyn [Forum Guidelines] [My Articles]


        - before you ask a question here, search CodeProject, then Google - the quality and detail of your question reflects on the effectiveness of the help you are likely to get - use the code block button (PRE tags) to preserve formatting when showing multi-line code snippets


        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