Filenames and open file dialog
-
hello, i need help with my project for college, i am using visual studio 2008 and c# programming lang. I want to grab the file name or file path to put into a rich text document using an openfiledialog. Users are able to select the file using the openfiledialog, select the file, and then when they double click or press open, the file name is inserted into the richtextbox.... to insert the text i am using InsertText(""); thanks
-
hello, i need help with my project for college, i am using visual studio 2008 and c# programming lang. I want to grab the file name or file path to put into a rich text document using an openfiledialog. Users are able to select the file using the openfiledialog, select the file, and then when they double click or press open, the file name is inserted into the richtextbox.... to insert the text i am using InsertText(""); thanks
And what is the problem that you are having?
Why is common sense not common? Never argue with an idiot. They will drag you down to their level where they are an expert. Sometimes it takes a lot of work to be lazy Individuality is fine, as long as we do it together - F. Burns Help humanity, join the CodeProject grid computing team here
-
hello, i need help with my project for college, i am using visual studio 2008 and c# programming lang. I want to grab the file name or file path to put into a rich text document using an openfiledialog. Users are able to select the file using the openfiledialog, select the file, and then when they double click or press open, the file name is inserted into the richtextbox.... to insert the text i am using InsertText(""); thanks
You can use OpenFileDialog:
OpenFileDialog sfd = new OpenFileDialog(); sfd.Filter = filterString; if (sfd.ShowDialog() == DialogResult.OK) { string fileName = sfd.FileName; ... }
or FolderBrowserDialog:
FolderBrowserDialog fbd = new FolderBrowserDialog(); fbd.SelectedPath = tbInitialDir.Text; if (fbd.ShowDialog() == DialogResult.OK) { string filePath = fbd.SelectedPath; ... }
You should never use standby on an elephant. It always crashes when you lift the ears. - Mark Wallace C/C++ (I dont see a huge difference between them, and the 'benefits' of C++ are questionable, who needs inheritance when you have copy and paste) - fat_boy
-
You can use OpenFileDialog:
OpenFileDialog sfd = new OpenFileDialog(); sfd.Filter = filterString; if (sfd.ShowDialog() == DialogResult.OK) { string fileName = sfd.FileName; ... }
or FolderBrowserDialog:
FolderBrowserDialog fbd = new FolderBrowserDialog(); fbd.SelectedPath = tbInitialDir.Text; if (fbd.ShowDialog() == DialogResult.OK) { string filePath = fbd.SelectedPath; ... }
You should never use standby on an elephant. It always crashes when you lift the ears. - Mark Wallace C/C++ (I dont see a huge difference between them, and the 'benefits' of C++ are questionable, who needs inheritance when you have copy and paste) - fat_boy
-
Thanks for the code example, can u tell me another thing which is how i would put the string / filename into a rich text box ? thanks again ..
modified on Monday, March 29, 2010 3:52 PM
Didn't you say you were using InsertText()?
I know the language. I've read a book. - _Madmatt
-
Didn't you say you were using InsertText()?
I know the language. I've read a book. - _Madmatt
-
yeah like inserttext("hello") , but i don't know how to put it for a string .... is it like inserttext("string filename"); or ?
SRJ92 wrote:
but i don't know how to put it for a string
What do you think "hello" is? You get a string for the filepath back from the OpenFileDialog. You just put that string in the InsertText call. What's the problem?
A guide to posting questions on CodeProject[^]
Dave Kreskowiak Microsoft MVP Visual Developer - Visual Basic
2006, 2007, 2008
But no longer in 2009... -
SRJ92 wrote:
but i don't know how to put it for a string
What do you think "hello" is? You get a string for the filepath back from the OpenFileDialog. You just put that string in the InsertText call. What's the problem?
A guide to posting questions on CodeProject[^]
Dave Kreskowiak Microsoft MVP Visual Developer - Visual Basic
2006, 2007, 2008
But no longer in 2009...