Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 4018024
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 20, 20262026-05-20T09:55:56+00:00 2026-05-20T09:55:56+00:00

I am fiddling around with the following code. However, I need the file name

  • 0

I am fiddling around with the following code. However, I need the file name restructured from the C:\MY FOLDER\MY FILE format to the C:\\MY FOLDER\\MY FILE format. How can I do this?

Public Class Form1
    Private Sub TextBox1_Clicked(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles TextBox1.Click
        'OpenFileDialog1.Title = "Please Select a File"
        'OpenFileDialog1.InitialDirectory = "C:temp"

        OpenFileDialog1.ShowDialog()

    End Sub

    Private Sub OpenFileDialog1_FileOk(ByVal sender As System.Object, ByVal e As System.ComponentModel.CancelEventArgs) Handles OpenFileDialog1.FileOk

        Dim strm As System.IO.Stream
        strm = OpenFileDialog1.OpenFile()
        TextBox1.Text = OpenFileDialog1.FileName.ToString()
        If Not (strm Is Nothing) Then
            ''insert code to read the file data
            strm.Close()
            'MessageBox.Show("file closed")
        End If

    End Sub

    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click

        Dim FILEx As String = "C:\FILEPATH.txt"

        If System.IO.File.Exists(FILEx) = True Then
            Dim objWriter As New System.IO.StreamWriter(FILEx, False)
            objWriter.WriteLine(TextBox1.Text)
            objWriter.Close()
        End If
    End Sub
End Class
`code`

The code is rough.I am just testing some things out.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-20T09:55:57+00:00Added an answer on May 20, 2026 at 9:55 am

    EDIT (VB, not C#, booh :p)

    If you’re writing a explicit string like “C:\FILEPATH.txt” you need to double up the \ yourself. Otherwise VB will think \F is a special character. That or preceed the string with a @.

    So:

    "C:\\FILEPATH.txt"
    

    or

    @"C:\FILEPATH.txt"
    

    Internally VB will only see a single \
    So if, say, you’re getting the path from a textbox you don’t need to double the backslashes.

    EDIT

    Ok, so according to here VB.NET actually does indeed not escape backslashes. Consider my answer useless then. (Although perhaps I educated some C-sharper out there… ? (I know I know, I’m grasping here :p)

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Whilst running test code from this question and fiddling with the JVM's thread stack
I'm fiddling with calling DLLs from C#, and came across the need to define
After fiddling around with an issue I am having I have come to this
I have this, and i've been fiddling around with it for a while but
ok, so I'm doing ProjectEuler Problem #14, and I'm fiddling around with optimizations in
I have an interface, written in C#, defined as this : public interface IWidget
I'm fiddling around with the C/C++ version of Eclipse to build a simple GTK
I recently started fiddling around with as3, which look pretty good, problem is I
I'm just fiddling around with user scripts in chrome right now, so please bear
I am fiddling around with a dialog that pops up and displays an alarm

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.