Advertisement
Java_Volume1 Files/ File Controls/ Input/ Output #88801

App.Path Thing

Correct Reference to Files in App.Path. For Newbies and for all who get Errors and don't know why. If you think this deserves a Vote, then do so, if not, then don't. I just wanted to explain a common error source !

AI

AI சுருக்கம்: This codebase represents a historical implementation of the logic described in the metadata. Our preservation engine analyzes the structure to provide context for modern developers.

மூலக் குறியீடு
original-source
After seeing so many wrong codes on this, I decided to clear things up a bit.
If you want to refer to a file located in app.path, nearly everyone writes
SomeVar$ = App.Path & "\SomeFile.txt"
What if the Program is located in the Root-Directory ? It gives a Run-Time Error because of the "\\", since App.Path returns "C:\" for example, then appends "\SomeFile.txt", which results in "C:\\SomeFile.txt".
ONE correct way would be :
Dim SourceFile As String
If Right$(App.Path, 1) = "\" Then
 SourceFile = App.Path & "SomeFile.txt"
Else
 SourceFile = App.Path & "\SomeFile.txt"
End If
This is the way I use, if there are any other, please put it in the comments.
அசல் கருத்துகள் (3)
வேபேக் மெஷினிலிருந்து (Wayback Machine) மீட்டெடுக்கப்பட்டது