Getox Posted September 14, 2005 Posted September 14, 2005 Is there any way to just get the filename without the path? example: you select file to open and click Open, it then puts the filename without the path like C:\blah\blah.ext it will put blah.ext anyone know? Quote Page Edit 2.0 Alpha 2 OUT NOW! - Download Now -
Administrators PlausiblyDamp Posted September 14, 2005 Administrators Posted September 14, 2005 Once you have the full path you coul just use the Path class to break it down. Dim FullPath As String Dim FileNameOnly As String If OpenFileDialog1.ShowDialog = DialogResult.OK Then FullPath = OpenFileDialog1.FileName FileNameOnly = System.IO.Path.GetFileName(FullPath) End If Quote Posting Guidelines FAQ Post Formatting Intellectuals solve problems; geniuses prevent them. -- Albert Einstein
Getox Posted September 14, 2005 Author Posted September 14, 2005 Ah thanks for that, Makin a webpage editing prog and when adding images it adds C:\blah\blah to it... But anymore, Thanks :D Quote Page Edit 2.0 Alpha 2 OUT NOW! - Download Now -
mbacarra Posted September 16, 2005 Posted September 16, 2005 oh... since this topic is about the opendialog, i guess i could insert my question here as well. how come when the opendialogbox opens and i click the cancel button, the even causes an error. and for example i clicked the file that i want to open in the dialog box, but decided to not open it anymore (click the cancel button), the file is still open (assuming that my application opens files and views it in the application). Quote
Getox Posted September 16, 2005 Author Posted September 16, 2005 try this: OpenFileDialog.Title = ("Open File") OpenFileDialog.Filter = ("Text File (*.txt)|*.txt") If OpenFileDialog.ShowDialog() = DialogResult.OK Then 'Open file End If Quote Page Edit 2.0 Alpha 2 OUT NOW! - Download Now -
Leaders snarfblam Posted September 16, 2005 Leaders Posted September 16, 2005 I don't know if this is a property of the OpenFileDialog in .Net, but in the ActiveX version there is an property that is something like ErrorOnCancel to give you an option to throw an error when the user hits cancel. Quote [sIGPIC]e[/sIGPIC]
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.