matt09524 Posted September 20, 2005 Posted September 20, 2005 Just for clarity sake, while in project mode, where should I point code like: Private Sub TextBoxDescription_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles TextBoxDescription.TextChanged 'catch file errors If File.Exists("/wartext.txt") Then Dim StreamToDisplay As StreamReader 'point to where the file should be StreamToDisplay = New StreamReader("/wartext.txt") ' <--- is this correct "/wartext.txt" where does that point to? TextBoxDescription.Text = StreamToDisplay.ReadToEnd StreamToDisplay.Close() TextBoxDescription.Select(0, 0) Else TextBoxDescription.Text = ("File WARTEXT.TXT not found. Please re-install the program or contact your system administrator or local IT professional.") End If End Sub to look for the files that I need to work... c:\my documents\visual studio 2005\projects\project1\project1 \bin \obj \resources \my project which one of these five directories should I create "text" "image" and "data" directories for the program to look for, and will it remember that for the published build? Quote
Nate Bross Posted September 20, 2005 Posted September 20, 2005 I'm not positive, try removing the "/" from the code, that should, if I'm not mistaken, point to the same directory as the binary is located. Quote ~Nate� ___________________________________________ Please use the [vb]/[cs] tags on posted code. Please post solutions you find somewhere else. Follow me on Twitter here.
Nate Bross Posted September 20, 2005 Posted September 20, 2005 You could try this as well. Return System.AppDomain.CurrentDomain.BaseDirectory() Quote ~Nate� ___________________________________________ Please use the [vb]/[cs] tags on posted code. Please post solutions you find somewhere else. Follow me on Twitter here.
matt09524 Posted September 20, 2005 Author Posted September 20, 2005 so should I make a "text" directory inside the bin directory? I want the final build to have the app look in the text directory for these files. Quote
Leaders snarfblam Posted September 20, 2005 Leaders Posted September 20, 2005 Then I would say yes. Your bin folder on the development machine will generally be the program file folder on the end user machine. I don't know what your software is going to do, but keep in mind that limited users probably won't have access to write to the global "programs" folders (for example C:\Documents and Settings\All Users\Program Files\). Quote [sIGPIC]e[/sIGPIC]
matt09524 Posted September 21, 2005 Author Posted September 21, 2005 (edited) This is a read only application. I found that if I put text\readme.txt and put it in the bin\debug\text (text made by me) directory, then the program will read it from there. Private Sub TextBoxDescription_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles TextBoxDescription.TextChanged If File.Exists("text\readme.txt") Then Dim StreamToDisplay As StreamReader StreamToDisplay = New StreamReader("text\readme.txt") TextBoxDescription.Text = StreamToDisplay.ReadToEnd StreamToDisplay.Close() TextBoxDescription.Select(0, 0) Else TextBoxDescription.Text = ("File README.TXT not found. Please re-install the program or contact your system administrator or local IT professional.") End If End Sub This uses the try...catch method of file detection and then looks in the bin\text directory I made for the files.. I'm pretty sure this will be the same with deployment. Edited September 21, 2005 by matt09524 Quote
kejpa Posted September 21, 2005 Posted September 21, 2005 I never rely purely on filenames such as If File.Exists("textreadme.txt") Then better use the whole path If File.Exists(Application.StartUpPath & "\Text\textreadme.txt") HTH /Kejpa Quote
matt09524 Posted September 21, 2005 Author Posted September 21, 2005 Bleh! My code was wrong when I posted it.. it should have read text\readme.txt :) hmmm wait.. the \ was missing because I did not go back.. bug in this forum when posting VB code? Quote
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.