By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
424,983 Members | 2,082 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 424,983 IT Pros & Developers. It's quick & easy.

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

P: 9
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\ProductName 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\Local Settings\Application Data\assembly\dl3\30YRGKJ9.HZC\74ELH8JC.ZZX\2722e3 ac\e67c828d_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.
Apr 16 '07 #1
Share this Question
Share on Google+
13 Replies


P: 60
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
Apr 16 '07 #2

P: 9
Hi,
Thanks for your reply. I have already tried that and it doesnt seem like its helping.

Thanks,
Asim.
Apr 16 '07 #3

P: 60
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.
Apr 16 '07 #4

Expert 5K+
P: 8,434
Found this in the usenet archives. Don't know whether it will help or not...
Expand|Select|Wrap|Line Numbers
  1. Private Function ApplicationPath() As String
  2.   Return _
  3.   Path.GetDirectoryName([Assembly].GetExecutingAssembly().Location)
  4. End Function
Apr 17 '07 #5

P: 9
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.
Apr 17 '07 #6

P: 9
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\Local Settings\Application Data\assembly\dl3\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
Apr 17 '07 #7

P: 60
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
Apr 17 '07 #8

P: 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.Directorypath :

C:\Documents and Settings\azia\Local Settings\Application Data\assembly\dl3\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:
Expand|Select|Wrap|Line Numbers
  1. If VB.Right(AppPath, 1) = "\" Then
  2.                 m_sApplicationPath = My.Application.Info.DirectoryPath 
  3.             Else
  4.                 m_sApplicationPath = My.Application.Info.DirectoryPath & "\"
  5.             End If
  6.             sLicFileName = m_sApplicationPath & m_sLicName
  7.  
  8.  
  9. ------ Rebuild All started: Project: MMSJrnEx, Configuration: Debug Any CPU ------
  10. 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
  11.  
  12. \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
  13.  
  14. 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
  15. ========== Rebuild All: 1 succeeded, 0 failed, 0 skipped ==========
  16.  
  17.  
Apr 18 '07 #9

P: 9
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.
Apr 19 '07 #10

Expert 5K+
P: 8,434
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.
Apr 19 '07 #11

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

System.AppDomain.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.
Apr 19 '07 #12

P: 9
Hi,

Yes it works.

Thanks again.
Asim.
Apr 19 '07 #13

Expert 5K+
P: 8,434
Yes it works.
Thanks again.
Excellent! :)

I'm glad to see you resolved the problem, and hope we were some help.
Apr 19 '07 #14

Post your reply

Sign in to post your reply or Sign up for a free account.