|
-
Sep 9th, 2007, 09:34 PM
#1
Thread Starter
Frenzied Member
[RESOLVED] File Address's
Folders and textfiles in Solution Exployer have this address:
"C:\Documents and Settings\Toecutter\Start Menu\Programs\
What happins when the app is run on a different computer?
Shouldnt the address strings be:
"c:\Program Files\ so it will run on any computer?
Regards
toe
-
Sep 9th, 2007, 10:10 PM
#2
Re: File Address's
 Originally Posted by toecutter
Folders and textfiles in Solution Exployer have this address:
"C:\Documents and Settings\Toecutter\Start Menu\Programs\
No they don't. That's where shortcuts to an installed app will be placed, but the app itself and your project source files are very much not in that location.
Projects are stored in the own folder under the Visual Studio 2005\Projects folder under your My Documents folder, wherever that may be. Installed applications will normally be installed under their own folder under the Program Files folder, wherever that may be. If you use ClickOnce deployment then they will be installed under the current user's Documents and Settings folder, wherever that may be. The system is smart enough to know where these special folders are on different systems and place the application's files in the right place.
-
Sep 9th, 2007, 10:16 PM
#3
Thread Starter
Frenzied Member
Re: File Address's
I think understand...
So you are saying any address line i type in my code should be C:\Documents and Settings\Toecutter\Start Menu\Programs\ and then the publishing/ClickOnce function will sort it out?
regards
toe
-
Sep 9th, 2007, 10:57 PM
#4
Re: File Address's
no, if you want to use your applications root folder use
Code:
Application.StartUpPath
This will always get the folder where your application is stored. What you are putting for a path will only point to the programs folder for the start menu on your computer as your users will not have you as a user on their computer.
-
Sep 9th, 2007, 11:06 PM
#5
Thread Starter
Frenzied Member
Re: File Address's
This is so confusing lol.
When i add a folder or a textfile to my project by using the Add New Item.
What address do i type in my code for the folder or textfile when referencing them so any computer can use the app without it failing?
If i right click the folder or textfile in Solution Exployer window it shows the address as "C:\Documents and Settings\Toecutter\Start Menu\Programs\"
-
Sep 9th, 2007, 11:43 PM
#6
Re: File Address's
Can you show us a screen shot of what you're talking about because right-clicking a text file or folder in the Solution Explorer doesn't show any path at all as far as I can see. Basically, if you add an item to your project in the Solution Explorer then it will add that file to your project folder, along with all your other source files. By default that will be, as I posted previously, in a folder named Visual Studio 2005\Projects\<Solution Name>\<Project Name> under your My Documents folder. Exactly where that is is of no consequence. When you debug your project it is compiled to the bin\Debug folder under that. Exactly where that is is of no consequence. If you use Application.StartupPath in your code then you will always get the path to the folder containing your executable, no matter where that is. You also have direct access to the paths of other special folders, like the current user's My Documents folder and the Program Files folder via special properties. The absolute path is of no concern to you.
-
Sep 9th, 2007, 11:56 PM
#7
Thread Starter
Frenzied Member
Re: File Address's
This is the properties of the xxxxx.txt textfile in the jobs folder

It works fine when testing on this computer (1st pc).
I Published the project installed it on my laptop(2nd pc) and it fails because it carnt find the address in the screen shot.
C:\Documents and Settings\Toecutter\My Documents\Visual Studio 2008\Projects\StickFrameExpress\StickFrameExpress\Jobs\xxxxx.txt because the computer name is mick not toecutter.
regards
toe
-
Sep 10th, 2007, 12:08 AM
#8
Frenzied Member
Re: File Address's
Perhaps this:
My.Computer.Resource
Or My.Resources, and pick w/e you want
-
Sep 10th, 2007, 12:42 AM
#9
Re: File Address's
Twice you said that your text file was under the path:
 Originally Posted by toecutter
C:\Documents and Settings\Toecutter\Start Menu\Programs\
Twice I said it wasn't:
 Originally Posted by jmcilhinney
Basically, if you add an item to your project in the Solution Explorer then it will add that file to your project folder, along with all your other source files. By default that will be, as I posted previously, in a folder named Visual Studio 2005\Projects\<Solution Name>\<Project Name> under your My Documents folder.
Now, read the path in your screen shot and tell me again where the file is located! We can't help you if you can't even convey to us the information that's on your screen.
Now, as I also said previously, that path is makes no difference whatsoever. You should NEVER be using that path ANYWHERE in your code. THat is a SOURCE file, just like your VB code files. Do you ever refer to your VB code files in code?
You are supposed to place that file in a standard location. Standard locations include the program folder, application data folder, etc., etc. Where do you want the text file to be located on a deployed system? You obviously don't want it to be in your project folder because that will obviously not exist on any other system. The easiest option is the program folder. In that case you simply set the Copy To Output Directory property of the file to Copy If Newer and it will be copied to the bin\Debug and bin\Release folders, EXACTLY where your executable is copied to. Then you can, as we have posted twice already, use Application.StartupPath to get the folder path.
-
Sep 10th, 2007, 01:38 AM
#10
Thread Starter
Frenzied Member
Re: File Address's
C:\Documents and Settings\Toecutter\My Documents\Visual Studio 2008\Projects\StickFrameExpress\StickFrameExpress\Jobs\xxxxx.txt is the path in the screen shot.
-
Sep 10th, 2007, 01:45 AM
#11
Re: File Address's
 Originally Posted by toecutter
C:\Documents and Settings\Toecutter\My Documents\Visual Studio 2008\Projects\StickFrameExpress\StickFrameExpress\Jobs\xxxxx.txt is the path in the screen shot.
I know that, and that's exactly what I said it would be... twice. I don't know how many times I can say the same thing: that path is irrelevant. That's where your project source files go. You do not access your project source files in code, so you never have to access that path. Either set the Copy To Output Directory property of that file to Copy If Newer and then access the copy in the output folder using Application.StartupPath as the folder path OR put it in some other standard folder and use the appropriate property to get that path.
-
Sep 10th, 2007, 02:34 AM
#12
Thread Starter
Frenzied Member
Re: File Address's
ok, i finally got it through this thick besser block head of mine
this
Code:
("C:\Documents and Settings\Toecutter\My Documents\Visual Studio 2008\Projects\StickFrameExpress\StickFrameExpress\Jobs\xxxxx.txt")
should be
Code:
(Application.StartupPath & "\Jobs\xxxxx.txt")
Sorry for being so dumb
Published tested on laptop and desktop and alls good.
thanks heaps
toe
-
Sep 10th, 2007, 02:35 AM
#13
Re: [RESOLVED] File Address's
Gold star.
-
Sep 10th, 2007, 02:50 AM
#14
Thread Starter
Frenzied Member
Re: [RESOLVED] File Address's
 Originally Posted by jmcilhinney
Gold star. 
Thanks
And you should get bundles of $$$$$$$
-
Sep 10th, 2007, 01:18 PM
#15
Re: [RESOLVED] File Address's
 Originally Posted by toecutter
Thanks
And you should get bundles of $$$$$$$

I have a feeling that he does
-
Sep 10th, 2007, 10:26 PM
#16
Thread Starter
Frenzied Member
Re: [RESOLVED] File Address's
I just came acroos a problem with the 2008 published version that i managed to fix.
I have a empty folder called Jobs in the project, now it wasnt being included in the published version for some reason so i placed a text file in it and now it was included when i published it again.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|