Home>
Select the folder to save and display the path in the textbox.
I want to check the textbox path and save the file.
However, when a folder is selected, it cannot be saved without a \ mark at the end.
How can I put a backslash at the end of the path?
Thank you.
private void button1_Click (object sender, EventArgs e)
{
string path = textBox1.Text;
</// Omitted since other operations from here
}
private void button2_Click (object sender, EventArgs e)
{
FolderBrowserDialog fbd = new FolderBrowserDialog ();
if (fbd.ShowDialog () == DialogResult.OK)
{
textBox1.Text = fbd.SelectedPath;
}
}
What I did
string path = textBox1.Text + "\";
It was useless.
-
Answer # 1
-
Answer # 2
string path = textBox1.Text + @ "\";
-
Answer # 3
\ is an escape character, so if you want to use this character in an ordinary string, you must double it with "\\"
If you go around with "C # escape character", you will get explanations about that.
Related articles
- how to select c # created file
- python 3x - how to add a two-dimensional array
- javascript - i want to add file to filelist
- java - how to add a local jar with maven
- python - how to read/write csv file on windows
- how to backup html and css files
- ruby - how to add id to link_to url
- html - how to add ◯ to letters
- how to add keys and elements of vba dictionary
- python - how to add a list to a list with a zip function
- java - i don't know how to add up the numbers in the list
- java - how to run jar file from shell
- c # - how to get the path before the folder
- c # - i don't know how to define the condition for if
- c # - how to join in linq (join)
- java - how to set the file path for command line arguments
- ruby - how to create a seed file associated with user
- c # async/await result how to use
- python - how to read a text file and distribute it
- i don't know how to save an image (jpg format) from a psd file
Related questions
- [c #] execute tasks with different types as return values in parallel, and calculate by combining the results
- i want to pass an argument to mainwindow () and execute it [wpf net framework c #]
- c # - converts 6 digits of japanese calendar with unknown year to 8 digits of western calendar
- how to save datagridview as xml file in c #
- about c # wpf keydown event
- c # - systemnullreferenceexceptio exception in webview 2
- c # - unrecognized fields are null when deserialized with messagepack
- c # - i want to put a thread to sleep for a long time
- i want itextsharp to display table borders twice (c #)
- c # - mstest library file name is too long and build error
It is best to use
System.IO.Path.Combine ()
instead of string concatenation when creating the full path of the saved file.