Results 1 to 16 of 16

Thread: [RESOLVED] File Address's

  1. #1

    Thread Starter
    Frenzied Member toecutter's Avatar
    Join Date
    Apr 2006
    Location
    Brisbane, Australia
    Posts
    1,160

    Resolved [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

  2. #2
    Super Moderator jmcilhinney's Avatar
    Join Date
    May 2005
    Location
    Sydney, Australia
    Posts
    111,221

    Re: File Address's

    Quote 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.
    Why is my data not saved to my database? | MSDN Data Walkthroughs
    VBForums Database Development FAQ
    My CodeBank Submissions: VB | C#
    My Blog: Data Among Multiple Forms (3 parts)
    Beginner Tutorials: VB | C# | SQL

  3. #3

    Thread Starter
    Frenzied Member toecutter's Avatar
    Join Date
    Apr 2006
    Location
    Brisbane, Australia
    Posts
    1,160

    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

  4. #4
    Frenzied Member bmahler's Avatar
    Join Date
    Oct 2005
    Location
    Somewhere just west of the Atlantic
    Posts
    1,568

    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.
    Boooya
    • Visual Studio 2008 Professional
    • Don't forget to use [CODE]your code here[/CODE] when posting code
    • Don't forget to rate helpful posts!
    • If you're question was answered please mark your thread [Resolved]


    Code Contributions:
    PHP
    PHP Image Gallery v1.0PHP Image Gallery v2.0
    VB 2005
    Find Computers on a networkSimple License EncryptionSQL Server Database Access dllUse Reflection to Return Crystal ReportDocumentSilently Print PDFGeneric Xml Serailizer


    Useful Links: (more to come)
    MSDN (The first and foremost)MSDN Design Guidelines API Reference • Inno Setup CompilerInno Setup PreprocessorISTool - Fairly easy to use GUI for creating inno setup projects • Connection StringsNAnt -Automated BuildsCruise Control .NET - Frontend for automated builds

  5. #5

    Thread Starter
    Frenzied Member toecutter's Avatar
    Join Date
    Apr 2006
    Location
    Brisbane, Australia
    Posts
    1,160

    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\"

  6. #6
    Super Moderator jmcilhinney's Avatar
    Join Date
    May 2005
    Location
    Sydney, Australia
    Posts
    111,221

    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.
    Why is my data not saved to my database? | MSDN Data Walkthroughs
    VBForums Database Development FAQ
    My CodeBank Submissions: VB | C#
    My Blog: Data Among Multiple Forms (3 parts)
    Beginner Tutorials: VB | C# | SQL

  7. #7

    Thread Starter
    Frenzied Member toecutter's Avatar
    Join Date
    Apr 2006
    Location
    Brisbane, Australia
    Posts
    1,160

    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

  8. #8
    Frenzied Member Icyculyr's Avatar
    Join Date
    Aug 2007
    Location
    Australia
    Posts
    1,934

    Re: File Address's

    Perhaps this:

    My.Computer.Resource

    Or My.Resources, and pick w/e you want

  9. #9
    Super Moderator jmcilhinney's Avatar
    Join Date
    May 2005
    Location
    Sydney, Australia
    Posts
    111,221

    Re: File Address's

    Twice you said that your text file was under the path:
    Quote Originally Posted by toecutter
    C:\Documents and Settings\Toecutter\Start Menu\Programs\
    Twice I said it wasn't:
    Quote 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.
    Why is my data not saved to my database? | MSDN Data Walkthroughs
    VBForums Database Development FAQ
    My CodeBank Submissions: VB | C#
    My Blog: Data Among Multiple Forms (3 parts)
    Beginner Tutorials: VB | C# | SQL

  10. #10

    Thread Starter
    Frenzied Member toecutter's Avatar
    Join Date
    Apr 2006
    Location
    Brisbane, Australia
    Posts
    1,160

    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.

  11. #11
    Super Moderator jmcilhinney's Avatar
    Join Date
    May 2005
    Location
    Sydney, Australia
    Posts
    111,221

    Re: File Address's

    Quote 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.
    Why is my data not saved to my database? | MSDN Data Walkthroughs
    VBForums Database Development FAQ
    My CodeBank Submissions: VB | C#
    My Blog: Data Among Multiple Forms (3 parts)
    Beginner Tutorials: VB | C# | SQL

  12. #12

    Thread Starter
    Frenzied Member toecutter's Avatar
    Join Date
    Apr 2006
    Location
    Brisbane, Australia
    Posts
    1,160

    Resolved 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

  13. #13
    Super Moderator jmcilhinney's Avatar
    Join Date
    May 2005
    Location
    Sydney, Australia
    Posts
    111,221

    Re: [RESOLVED] File Address's

    Gold star.
    Why is my data not saved to my database? | MSDN Data Walkthroughs
    VBForums Database Development FAQ
    My CodeBank Submissions: VB | C#
    My Blog: Data Among Multiple Forms (3 parts)
    Beginner Tutorials: VB | C# | SQL

  14. #14

    Thread Starter
    Frenzied Member toecutter's Avatar
    Join Date
    Apr 2006
    Location
    Brisbane, Australia
    Posts
    1,160

    Re: [RESOLVED] File Address's

    Quote Originally Posted by jmcilhinney
    Gold star.
    Thanks
    And you should get bundles of $$$$$$$

  15. #15
    Frenzied Member bmahler's Avatar
    Join Date
    Oct 2005
    Location
    Somewhere just west of the Atlantic
    Posts
    1,568

    Re: [RESOLVED] File Address's

    Quote Originally Posted by toecutter
    Thanks
    And you should get bundles of $$$$$$$
    I have a feeling that he does
    Boooya
    • Visual Studio 2008 Professional
    • Don't forget to use [CODE]your code here[/CODE] when posting code
    • Don't forget to rate helpful posts!
    • If you're question was answered please mark your thread [Resolved]


    Code Contributions:
    PHP
    PHP Image Gallery v1.0PHP Image Gallery v2.0
    VB 2005
    Find Computers on a networkSimple License EncryptionSQL Server Database Access dllUse Reflection to Return Crystal ReportDocumentSilently Print PDFGeneric Xml Serailizer


    Useful Links: (more to come)
    MSDN (The first and foremost)MSDN Design Guidelines API Reference • Inno Setup CompilerInno Setup PreprocessorISTool - Fairly easy to use GUI for creating inno setup projects • Connection StringsNAnt -Automated BuildsCruise Control .NET - Frontend for automated builds

  16. #16

    Thread Starter
    Frenzied Member toecutter's Avatar
    Join Date
    Apr 2006
    Location
    Brisbane, Australia
    Posts
    1,160

    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
  •  



Click Here to Expand Forum to Full Width