My.Application.Info.Directory wrong path (Urgent please)

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • asimzia
    New Member
    • Apr 2007
    • 9

    My.Application.Info.Directory wrong path (Urgent please)

    Hi there ,

    I have used app.path in VB6.0 and it gives me exact location of my VB Application that is on client pc normally it is C:\Program Files\ProductNa me and on my PC it is C:\Development\ VB.
    Using VS 2005 (VB) i am getting this kind of path :


    C:\Documents and Settings\azia\L ocal Settings\Applic ation Data\assembly\d l3\30YRGKJ9.HZC \74ELH8JC.ZZX\2 722e3ac\e67c828 d_2b80c701



    and my application is trying to find a particular file and obviously it won't be able to find this file in there.

    and i actually wanted to get the exact location of the VB application (VS2005)

    can anyone please help me in order to provide the similar thing like app.path (VB 6.0) in VB.NET

    Thanks,
    Asim.
  • fauxanadu
    New Member
    • Mar 2007
    • 60

    #2
    in VB.NET, when you debug a program or build a program, it puts it in a directory such as bin/debug/yadayada. You can change this behavior in the My Project file of VB.NET... double click it and change the debug and build paths to the directory where the files they need to locate are located

    Comment

    • asimzia
      New Member
      • Apr 2007
      • 9

      #3
      Hi,
      Thanks for your reply. I have already tried that and it doesnt seem like its helping.

      Thanks,
      Asim.

      Comment

      • fauxanadu
        New Member
        • Mar 2007
        • 60

        #4
        I have found that sometimes it works and sometimes it ignores the settings as well. When it ignores the settings your best bet is to just move the external files to the directory where it is intended to be. If you do not know where it is trying to run the program from, have a messagebox spit out the string for the path to the application and copy the files there. Let me know if this works. If not i'll look deeper into the issue.

        Comment

        • Killer42
          Recognized Expert Expert
          • Oct 2006
          • 8429

          #5
          Found this in the usenet archives. Don't know whether it will help or not...
          Code:
          Private Function ApplicationPath() As String
            Return _
            Path.GetDirectoryName([Assembly].GetExecutingAssembly().Location)
          End Function

          Comment

          • asimzia
            New Member
            • Apr 2007
            • 9

            #6
            Originally posted by fauxanadu
            I have found that sometimes it works and sometimes it ignores the settings as well. When it ignores the settings your best bet is to just move the external files to the directory where it is intended to be. If you do not know where it is trying to run the program from, have a messagebox spit out the string for the path to the application and copy the files there. Let me know if this works. If not i'll look deeper into the issue.

            Thanks very much, let me have a look and i will let you know.

            Thanks once again.

            Comment

            • asimzia
              New Member
              • Apr 2007
              • 9

              #7
              Hi,
              Thanks for your help, the thing is it is creating a required file in that strange location and picking the file information from there as well. My question is why it is not giving me the path which is actually the location of the product. I have installed my product on a test pc and its location is

              C:\Program Files\My Product

              So when i wanted to have this path (which is my application path), i should get this folder, so i can copy the file over to this folder. But when i am trying i am getting this path even on my pc (which is a development pc) and something to similar to this on test pc as well.

              One thing i wanted to ask you is why my all assemblies (.NET one and interop ones) are copied into this path which is defined below:

              C:\Documents and Settings\azia\L ocal Settings\Applic ation Data\assembly\d l3\30YRGKJ9.HZC \74ELH8JC.ZZX

              and in the above defined path i have all my assemblies in different folders and each folder hold one assembly file with one inf file which tells you the path of the actual folder.

              If you see this will become bit harder, if i installed my product on test pc for everyone who uses that machine using Administrative privileges and logged on with other user and tried to run it will give me an error coz the folder azia (user) is only accessible by the user itself.



              Do you think i am doing something wrong, how can i configure these path settings, i am bit confused as in VB6.0 there is nothing like this i just used the simple procedure which uses app.path which gives the location of the Folder. Please if you can tell me further on this , then i will be really greatful to you.

              Thanks for your time and your help.
              Asim

              Comment

              • fauxanadu
                New Member
                • Mar 2007
                • 60

                #8
                I think the issue might be that VB.NET stores new projects in a folder based on your windows user name. There is an option that allows you to change the default location that VB.Net stores the projects in. If this is not the problem, please give me the following pieces of information so I can try to figure this one out:

                Code Snippet you are using
                Build Output from a standard debug build
                Start a new project and let me know what the Application Directory is

                Also, if you could clarify something: Does the path it save it in change everytime you build the application?

                Sorry this is taking so long, but it is an odd error

                Comment

                • asimzia
                  New Member
                  • Apr 2007
                  • 9

                  #9
                  When I create a new project which is Extensibility based, it gives me exactly the path which is my development folder (C:\Development \VB.NET), So i think this is not the case.

                  The path is not changing it will seems like it is same everytime and always go to this path when i try to use My.Application. Info.Directoryp ath :

                  C:\Documents and Settings\azia\L ocal Settings\Applic ation Data\assembly\d l3\30YRGKJ9.HZC \74ELH8JC.ZZX

                  I have also attached the code snippet and tried to attach build output from debug but it doesnt allow me to add, so is there any possibility i can email it to you, what i have done is i have copied and pasted the top few lines and the few lines from the end of the output build.

                  Thanks for you help and support.


                  Code Snippet:
                  Code:
                  If VB.Right(AppPath, 1) = "\" Then
                                  m_sApplicationPath = My.Application.Info.DirectoryPath 
                              Else
                                  m_sApplicationPath = My.Application.Info.DirectoryPath & "\"
                              End If
                              sLicFileName = m_sApplicationPath & m_sLicName
                  
                  
                  ------ Rebuild All started: Project: MMSJrnEx, Configuration: Debug Any CPU ------
                  C:\Program Files\Microsoft Visual Studio 8\SDK\v2.0\bin\LC.exe /target:MMSJrnEx.dll /complist:"My Project\licenses.licx" /outdir:obj\Debug\ /i:"C:\Program Files\ComponentOne Studio.NET\bin\C1.Common.dll" /i:"C:\Program Files\ComponentOne Studio.NET\bin\c1.win.c1sizer.dll" /i:"C:\Program Files\ComponentOne Studio.NET\bin\C1.Win.C1TrueDBGrid.dll" /i:..\ExcelUtils.NET\bin\ExcelUtils.dll /i:..\OfficePIAs\Interop.Excel.dll /i:..\OfficePIAs\Interop.Office.dll /i:C:\WINDOWS\Microsoft.NET\Framework\v2.0.50727
                  
                  \Microsoft.VisualBasic.Compatibility.Data.dll /i:C:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\Microsoft.VisualBasic.Compatibility.dll /i:..\SageMMS1\Sage.Accounting.Financials.dll /i:..\SageMMS1\Sage.Common.dll /i:..\SageMMS1\Sage.ObjectStore.dll /i:..\SageMMS1\Sage.Utils.dll /i:..\OfficePIAs\SKCLNET.dll /i:C:\WINDOWS\Microsoft.NET\Framework\v2.0.50727
                  
                  EmailLicence.designer.vb EmailLicence.vb ErrorHandling.vb frmPostingOptionsBrowse.Designer.vb frmPostingOptionsBrowse.vb frmAccountBrowse.designer.vb frmAccountBrowse.vb FrmBrowse.designer.vb FrmBrowse.vb frmBrowseCalendar.designer.vb frmBrowseCalendar.vb frmCompanyList.designer.vb frmCompanyList.vb frmLic.designer.vb frmLic.vb frmLicUnlock.designer.vb frmLicUnlock.vb frmLogon.vb Globals.vb LicenceMethods.designer.vb LicenceMethods.vb LicenseLocation.designer.vb LicenseLocation.vb LoginDetails.vb MMSJournal.vb MMSJournalDetail.vb MMSJrnErrors.vb MMSJrnEx.vb MMSJrnRangeNames.vb MMSJrnRanges.vb "My Project\AssemblyInfo.vb" "My Project\Application.Designer.vb" "My Project\Resources.Designer.vb" "My Project\Settings.Designer.vb" PPPFunc.vb Progress.designer.vb Progress.vb
                  ========== Rebuild All: 1 succeeded, 0 failed, 0 skipped ==========

                  Comment

                  • asimzia
                    New Member
                    • Apr 2007
                    • 9

                    #10
                    Hi There,

                    Any further progress to this problem, please let me know because i have to release my application as soon as possible.

                    Any help will be really appreciated.

                    Thanks,
                    Asim.

                    Comment

                    • Killer42
                      Recognized Expert Expert
                      • Oct 2006
                      • 8429

                      #11
                      Originally posted by asimzia
                      Hi There,

                      Any further progress to this problem, please let me know because i have to release my application as soon as possible.

                      Any help will be really appreciated.
                      Have you checked MS's VB6 -> VB.Net upgrade info? It does seem to cover a lot of the differences, perhaps this is one of them.

                      Comment

                      • asimzia
                        New Member
                        • Apr 2007
                        • 9

                        #12
                        Hi There,
                        Thank you very much for your support and time, i was searching on internet i found this :

                        System.AppDomai n.CurrentDomain .BaseDirectory( )

                        It seems like it is returning the required path on my machine (development), i just have to test this thing on the deployment machine, hopefully it will work.

                        I will let you know guys, but thanks very much for every single thing you told me to try.

                        Thanks,
                        Asim.

                        Comment

                        • asimzia
                          New Member
                          • Apr 2007
                          • 9

                          #13
                          Hi,

                          Yes it works.

                          Thanks again.
                          Asim.

                          Comment

                          • Killer42
                            Recognized Expert Expert
                            • Oct 2006
                            • 8429

                            #14
                            Originally posted by asimzia
                            Yes it works.
                            Thanks again.
                            Excellent! :)

                            I'm glad to see you resolved the problem, and hope we were some help.

                            Comment

                            Working...