Click here to Skip to main content
15,927,179 members
Home / Discussions / Visual Basic
   

Visual Basic

 
GeneralRe: windows based print on dot matrix printer Pin
Dave Kreskowiak14-Nov-07 5:46
mveDave Kreskowiak14-Nov-07 5:46 
QuestionExit button Pin
Dave McCool14-Nov-07 0:27
Dave McCool14-Nov-07 0:27 
AnswerRe: Exit button Pin
nilam1114-Nov-07 0:38
nilam1114-Nov-07 0:38 
GeneralRe: Exit button Pin
Dave McCool14-Nov-07 0:59
Dave McCool14-Nov-07 0:59 
GeneralRe: Exit button Pin
Tom Deketelaere14-Nov-07 1:07
professionalTom Deketelaere14-Nov-07 1:07 
QuestionFile Location Pin
Dave McCool14-Nov-07 0:18
Dave McCool14-Nov-07 0:18 
AnswerRe: File Location Pin
Tom Deketelaere14-Nov-07 1:09
professionalTom Deketelaere14-Nov-07 1:09 
AnswerRe: File Location Pin
Dave Kreskowiak14-Nov-07 5:44
mveDave Kreskowiak14-Nov-07 5:44 
You should always use the fully qualified path to a file and not just assume the current directory is the one you think it is.

If your file is in the same folder as your .EXE, you can get the full path using something like:
Public Shared Function GetFullPathToFile(ByVal filename As String) As String
    Return Path.Combine(Application.StartupPath, filename)
End Function


If it's in a subfolder of your application's folder, there are several different ways of building the path. A simple implementation would be something like:
Public Shared Function GetFullPathToFileInDataFolder(ByVal filename As String) As String
    ' Build the full path to the Data folder in our the folder our .EXE is in.
    ' You could also get this path from a config file, or some other data store.
    Dim dataFolderPath As String = Path.Combine(Application.StartupPath, "Data")

    ' Then build the path to the requested file
    Return Path.Combine(dataFolderPath, filename)
End Function



A guide to posting questions on CodeProject[^]

Dave Kreskowiak
Microsoft MVP
Visual Developer - Visual Basic
     2006, 2007


Questionhw to get index Pin
poonams14-Nov-07 0:15
poonams14-Nov-07 0:15 
AnswerRe: hw to get index Pin
Tom Deketelaere14-Nov-07 1:12
professionalTom Deketelaere14-Nov-07 1:12 
QuestionListbox Pin
dexter970314-Nov-07 0:07
dexter970314-Nov-07 0:07 
AnswerRe: Listbox Pin
The ANZAC14-Nov-07 0:33
The ANZAC14-Nov-07 0:33 
AnswerRe: Listbox Pin
ChandraRam14-Nov-07 1:23
ChandraRam14-Nov-07 1:23 
QuestionApp.Config?? Pin
barney_197213-Nov-07 23:51
barney_197213-Nov-07 23:51 
AnswerRe: App.Config?? Pin
Dave Kreskowiak14-Nov-07 5:32
mveDave Kreskowiak14-Nov-07 5:32 
QuestionHow to start each text line in a new line??? Pin
Support12313-Nov-07 22:21
Support12313-Nov-07 22:21 
AnswerRe: How to start each text line in a new line??? Pin
Christian Graus13-Nov-07 22:31
protectorChristian Graus13-Nov-07 22:31 
GeneralRe: How to start each text line in a new line??? Pin
Support12313-Nov-07 22:44
Support12313-Nov-07 22:44 
GeneralRe: How to start each text line in a new line??? Pin
Support12313-Nov-07 22:51
Support12313-Nov-07 22:51 
QuestionRe: How to start each text line in a new line??? Pin
Support12313-Nov-07 23:45
Support12313-Nov-07 23:45 
QuestionDataGridView Pin
SekharOne13-Nov-07 21:58
SekharOne13-Nov-07 21:58 
AnswerRe: DataGridView Pin
Dave Kreskowiak14-Nov-07 5:30
mveDave Kreskowiak14-Nov-07 5:30 
Questiontreeview not maintaining the expanded view after postback Pin
uglyeyes13-Nov-07 19:14
uglyeyes13-Nov-07 19:14 
AnswerRe: treeview not maintaining the expanded view after postback Pin
Dave Kreskowiak14-Nov-07 5:27
mveDave Kreskowiak14-Nov-07 5:27 
Questiondelete a line of text from a text file Pin
iSeeGhosts13-Nov-07 16:42
iSeeGhosts13-Nov-07 16:42 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.