Publishing in vb.net

Started by
3 comments, last by benryves 15 years, 10 months ago
Hey, ive recently created a simple tetris game in vb.net. i want to publish it but after it finishes publishing and installing, when i run it, it gives me an error stating: Image Hosted by ImageShack.us<br/> Can anyone help me here?
The wheel is spinning, but the hampster is dead!
Advertisement
It looks like you hard coded the path to your highscores file (which isn't wrong per se), and that you hard coded it as an absolute path, which only works on your computer. Try using a relative path instead.

Tristam MacDonald. Ex-BigTech Software Engineer. Future farmer. [https://trist.am]

How would i do that? sorry bout my limited understanding, this is the only way ive been taught to do this.

My current line of code for this is:

FileSystem.FileOpen(1, Application.StartupPath & "\Highscores.txt", OpenMode.Input)


thanks
The wheel is spinning, but the hampster is dead!
Quote:Original post by AncientHunter
How would i do that? sorry bout my limited understanding, this is the only way ive been taught to do this.
My current line of code for this is:
*** Source Snippet Removed ***
thanks

Keep in mind that I am not very familiar with your environment (Mac user myself), but what if you try just using "highscores.txt" as the path? My rationale here is that the app should start with paths relative to the application, and if your code snippet is correct, Application.StartupPath is ending up in some temporary settings directory.

Tristam MacDonald. Ex-BigTech Software Engineer. Future farmer. [https://trist.am]

You should store such files in the user's own profile area, as you are not usually permitted to write back to the application's own directory unless you are running the application with administrative rights.

You can use the Environment class to work out where to store the data files. For example, this function:

    Private Function GetHighscorePath() As String        ' Using IO.Path.Combine allows this code to work on platforms that don't use \ as a directory seperator.        Dim RelativeName As String = IO.Path.Combine("AncientHunter", IO.Path.Combine("Tetris", "Highscores.txt"))        ' This bit uses the application data "special folder", which is tied to the current user.        Return IO.Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData), RelativeName)    End Function

...returns a filename in the form C:\Users\Ben\AppData\Roaming\AncientHunter\Tetris\Highscores.txt (the exact path depends on the username and version of Windows).

You may need to copy (IO.File.Copy()) a default file there the first time your app is run (use IO.File.Exists() to check first) which could come from the application's own directory. I strongly recommend you take a look at the System.IO namespace, rather than using features such as FileSystem.FileOpen which are provided for backwards compatibility with VB6.

[Website] [+++ Divide By Cucumber Error. Please Reinstall Universe And Reboot +++]

This topic is closed to new replies.

Advertisement