Jump to content
Xtreme .Net Talk

Recommended Posts

Posted

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?

Posted
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.

~Nate�

___________________________________________

Please use the [vb]/[cs] tags on posted code.

Please post solutions you find somewhere else.

Follow me on Twitter here.

Posted

You could try this as well.

Return System.AppDomain.CurrentDomain.BaseDirectory()

~Nate�

___________________________________________

Please use the [vb]/[cs] tags on posted code.

Please post solutions you find somewhere else.

Follow me on Twitter here.

  • Leaders
Posted
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\).
[sIGPIC]e[/sIGPIC]
Posted (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 by matt09524
Posted

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

Posted
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?

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...